RSTransform.fromComponents constructor

RSTransform.fromComponents({double rotation, double scale, double anchorX, double anchorY, double translateX, double translateY })

Creates an RSTransform from its individual components.

The rotation parameter gives the rotation in radians.

The scale parameter describes the uniform scale factor.

The anchorX and anchorY parameters give the coordinate of the point around which to rotate.

The translateX and translateY parameters give the coordinate of the offset by which to translate.

This constructor computes the arguments of the new RSTransform constructor and then defers to that constructor to actually create the object. If many RSTransform objects are being created and there is a way to factor out the computations of the sine and cosine of the rotation (which are computed each time this constructor is called) and reuse them over multiple RSTransform objects, it may be more efficient to directly use the more direct new RSTransform constructor instead.

Implementation

factory RSTransform.fromComponents({
  double rotation,
  double scale,
  double anchorX,
  double anchorY,
  double translateX,
  double translateY
}) {
  final double scos = math.cos(rotation) * scale;
  final double ssin = math.sin(rotation) * scale;
  final double tx = translateX + -scos * anchorX + ssin * anchorY;
  final double ty = translateY + -ssin * anchorX - scos * anchorY;
  return new RSTransform(scos, ssin, tx, ty);
}