Matrix samplerMatrix

The matrix transformation for this RenderTextureQuad to transform target coordinates to sampler coordinates.

Sampler coordinate are in the range from (0, 0) to (1, 1). Target coordinates take the pixelRatio into account.

Source

Matrix get samplerMatrix {

  var pr = this.pixelRatio;
  var sx = 1.0 / this.renderTexture.width;
  var sy = 1.0 / this.renderTexture.height;

  if (rotation == 0) {
    var tx = sourceRectangle.left + offsetRectangle.left;
    var ty = sourceRectangle.top + offsetRectangle.top;
    return new Matrix(sx * pr, 0.0, 0.0, sy * pr, sx * tx, sy * ty);
  } else if (rotation == 1) {
    var tx = sourceRectangle.right - offsetRectangle.top;
    var ty = sourceRectangle.top + offsetRectangle.left;
    return new Matrix(0.0, sy * pr, 0.0 - sx * pr, 0.0, sx * tx, sy * ty);
  } else if (rotation == 2) {
    var tx = sourceRectangle.right - offsetRectangle.left;
    var ty = sourceRectangle.bottom - offsetRectangle.top;
    return new Matrix(0.0 - sx * pr, 0.0, 0.0, 0.0 - sy * pr, sx * tx, sy * ty);
  } else if (rotation == 3) {
    var tx = sourceRectangle.left + offsetRectangle.top;
    var ty = sourceRectangle.bottom - offsetRectangle.left;
    return new Matrix(0.0, 0.0 - sy * pr, sx * pr, 0.0, sx * tx, sy * ty);
  } else {
    throw new Error();
  }
}