license import { GPGPUProgram } from './gpgpu_math' ; export class FlipLeftRightProgram implements GPGPUProgram { variableNames = [ 'Image' ] ; outputShape : number [ ] = [ ] ; userCode : string ; constructor ( imageShape ) { const imageWidth = imageShape [ 2 ] ; this . outputShape = imageShape ; this . userCode = `
        void main() {
          ivec4 coords = getOutputCoords();
          int x = coords[2];

          int coordX = ${ imageWidth } - x - 1;
          float outputValue;
          if(coordX >= 0 && coordX < ${ imageWidth }) {
            outputValue = getImage(coords[0], coords[1], coordX, coords[3]);
          } else {
            outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);
          }
          setOutput(outputValue);
        }
    ` ; } }