drawMatrix property Null safety

Matrix drawMatrix

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

Texture coordinates are in the range from (0, 0) to (width, height). Target coordinates take the pixelRatio into account.

Implementation

Matrix get drawMatrix {
  final pr = pixelRatio;

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