setTransform method

GMatrix setTransform(
  1. double x,
  2. double y,
  3. double pivotX,
  4. double pivotY,
  5. double scaleX,
  6. double scaleY,
  7. double skewX,
  8. double skewY,
  9. double rotation,
)

Utility function that calculates directly the transformation for a DisplayObject.

Implementation

GMatrix setTransform(
  double x,
  double y,
  double pivotX,
  double pivotY,
  double scaleX,
  double scaleY,
  double skewX,
  double skewY,
  double rotation,
) {
  a = math.cos(rotation + skewY) * scaleX;
  b = math.sin(rotation + skewY) * scaleX;
  c = -math.sin(rotation - skewX) * scaleY;
  d = math.cos(rotation - skewX) * scaleY;
  tx = x - ((pivotX * a) + (pivotY * c));
  ty = y - ((pivotX * b) + (pivotY * d));
  return this;
}