Texture Scale Offset
500253
function LGraphTextureScaleOffset() {
            this.addInput("in", "Texture");
            this.addInput("scale", "vec2");
            this.addInput("offset", "vec2");
            this.addOutput("out", "Texture");
            this.properties = {
                offset: vec2.fromValues(0, 0),
                scale: vec2.fromValues(1, 1),
                precision: LGraphTexture.DEFAULT
            };
        }
700583
private static void adjustUncalibrated(FMatrixRMaj rectifyLeft, FMatrixRMaj rectifyRight,
										   RectangleLength2D_F32 bound, float scale) {
		// translation
		float deltaX = -bound.x0*scale;
		float deltaY = -bound.y0*scale;

		// adjustment matrix
		SimpleMatrix A = new SimpleMatrix(3,3,true,new float[]{scale,0,deltaX,0,scale,deltaY,0,0,1});
		SimpleMatrix rL = SimpleMatrix.wrap(rectifyLeft);
		SimpleMatrix rR = SimpleMatrix.wrap(rectifyRight);

		rectifyLeft.set(A.mult(rL).getFDRM());
		rectifyRight.set(A.mult(rR).getFDRM());
	}
446686
public static void scale( double alpha , DMatrix2 a ) {
        a.a1 *= alpha;
        a.a2 *= alpha;
    }
1036146
def _symmetric_warp(c, magnitude:partial(uniform,size=4)=0, invert=False):
    ""
    m = listify(magnitude, 4)
    targ_pts = [[-1-m[3],-1-m[1]], [-1-m[2],1+m[1]], [1+m[3],-1-m[0]], [1+m[2],1+m[0]]]
    return _do_perspective_warp(c, targ_pts, invert)
1339147
public static void scaleDownToFit( Rectangle2D rectToFitIn, Rectangle2D toScale ) {
        double fitWidth = rectToFitIn.getWidth();
        double fitHeight = rectToFitIn.getHeight();

        double toScaleWidth = toScale.getWidth();
        double toScaleHeight = toScale.getHeight();

        if (toScaleWidth > fitWidth) {
            double factor = toScaleWidth / fitWidth;
            toScaleWidth = fitWidth;
            toScaleHeight = toScaleHeight / factor;
        }
        if (toScaleHeight > fitHeight) {
            double factor = toScaleHeight / fitHeight;
            toScaleHeight = fitHeight;
            toScaleWidth = toScaleWidth / factor;
        }
        toScale.setRect(0, 0, toScaleWidth, toScaleHeight);
    }
627944
def scale(self, dx=1.0, dy=1.0):
        '''
        

        '''
        self.width *= dx
        self.height *= dy
177536
private static void adjustCalibrated(DMatrixRMaj rectifyLeft, DMatrixRMaj rectifyRight,
										 DMatrixRMaj rectifyK,
										 RectangleLength2D_F64 bound, double scale) {
		// translation
		double deltaX = -bound.x0*scale;
		double deltaY = -bound.y0*scale;

		// adjustment matrix
		SimpleMatrix A = new SimpleMatrix(3,3,true,new double[]{scale,0,deltaX,0,scale,deltaY,0,0,1});
		SimpleMatrix rL = SimpleMatrix.wrap(rectifyLeft);
		SimpleMatrix rR = SimpleMatrix.wrap(rectifyRight);
		SimpleMatrix K = SimpleMatrix.wrap(rectifyK);

		// remove previous calibration matrix
		SimpleMatrix K_inv = K.invert();
		rL = K_inv.mult(rL);
		rR = K_inv.mult(rR);

		// compute new calibration matrix and apply it
		K = A.mult(K);

		rectifyK.set(K.getDDRM());
		rectifyLeft.set(K.mult(rL).getDDRM());
		rectifyRight.set(K.mult(rR).getDDRM());
	}
1085086
def calibrate_radiance(array, attributes, index):
    """"""
    offset = np.float32(attributes["radiance_offsets"][index])
    scale = np.float32(attributes["radiance_scales"][index])
    array = (array - offset) * scale
    return array
1292340
public static void scale( double alpha , DMatrix2x2 a ) {
        a.a11 *= alpha; a.a12 *= alpha;
        a.a21 *= alpha; a.a22 *= alpha;
    }
263730
public static void scaleIntrinsic(CameraPinhole param , double scale ) {
		param.width = (int)(param.width*scale);
		param.height = (int)(param.height*scale);
		param.cx *= scale;
		param.cy *= scale;
		param.fx *= scale;
		param.fy *= scale;
		param.skew *= scale;
	}
386508
def _zoom(scale:uniform=1.0, row_pct:uniform=0.5, col_pct:uniform=0.5):
    ""
    s = 1-1/scale
    col_c = s * (2*col_pct - 1)
    row_c = s * (2*row_pct - 1)
    return _get_zoom_mat(1/scale, 1/scale, col_c, row_c)
1325182
def _scale_tile(self, value, width, height):
        """"""
        try:
            return self._scale_cache[value, width, height]
        except KeyError:
            tile = pygame.transform.smoothscale(self.tiles[value], (width, height))
            self._scale_cache[value, width, height] = tile
            return tile
978878
def _build_scale_offset(self, dtype):
    """"""

    # tf.nn.fused_batch_norm accepts float16 batch data, but not scale/offset.
    if self._fused and dtype == tf.float16:
      dtype = tf.float32

    # The fused batch norm operation needs the beta, gamma variables,
    # so in this case we build them and set the trainable option according
    # to the values of _offset and _scale.
    self._beta = None
    if self._offset or self._fused:
      if self.BETA not in self._initializers:
        self._initializers[self.BETA] = create_beta_initializer()
      self._beta = tf.get_variable(
          self.BETA,
          dtype=dtype,
          shape=self._mean_shape,
          initializer=self._initializers[self.BETA],
          partitioner=self._partitioners.get(self.BETA, None),
          regularizer=self._regularizers.get(self.BETA, None),
          trainable=self._offset)

    self._gamma = None
    if self._scale or self._fused:
      if self.GAMMA not in self._initializers:
        self._initializers[self.GAMMA] = create_gamma_initializer()
      self._gamma = tf.get_variable(
          self.GAMMA,
          dtype=dtype,
          shape=self._mean_shape,
          initializer=self._initializers[self.GAMMA],
          partitioner=self._partitioners.get(self.GAMMA, None),
          regularizer=self._regularizers.get(self.GAMMA, None),
          trainable=self._scale)
343439
function setTextureProperties (texture, data) {
  var offset = data.offset || {x: 0, y: 0};
  var repeat = data.repeat || {x: 1, y: 1};
  var npot = data.npot || false;

  // To support NPOT textures, wrap must be ClampToEdge (not Repeat),
  // and filters must not use mipmaps (i.e. Nearest or Linear).
  if (npot) {
    texture.wrapS = THREE.ClampToEdgeWrapping;
    texture.wrapT = THREE.ClampToEdgeWrapping;
    texture.magFilter = THREE.LinearFilter;
    texture.minFilter = THREE.LinearFilter;
  }

  // Don't bother setting repeat if it is 1/1. Power-of-two is required to repeat.
  if (repeat.x !== 1 || repeat.y !== 1) {
    texture.wrapS = THREE.RepeatWrapping;
    texture.wrapT = THREE.RepeatWrapping;
    texture.repeat.set(repeat.x, repeat.y);
  }
  // Don't bother setting offset if it is 0/0.
  if (offset.x !== 0 || offset.y !== 0) {
    texture.offset.set(offset.x, offset.y);
  }
}
401879
def scale_to(self, width_height=Vector2()):
        """"""
        scale_amt = Vector2()
        scale_amt.X = float(width_height.X) / self.image.get_width()
        scale_amt.Y = float(width_height.Y) / self.image.get_height()
        self.set_scale(scale_amt)
616990
function LGraphTextureDepthRange() {
            this.addInput("Texture", "Texture");
            this.addInput("Distance", "number");
            this.addInput("Range", "number");
            this.addOutput("Texture", "Texture");
            this.properties = {
                distance: 100,
                range: 50,
                only_depth: false,
                high_precision: false
            };
            this._uniforms = {
                u_texture: 0,
                u_distance: 100,
                u_range: 50,
                u_camera_planes: null
            };
        }
373728
function(ratio) {
        this._texture.width = this.width * ratio;
        this._texture.height = this.height * ratio;
        this.downSampleRatio = ratio;
    }