You'll probably want this (transformation is a Matrix instance):
function withTransformation(transformation, block) {
context.save();
context.transform(
transformation.a,
transformation.b,
transformation.c,
transformation.d,
transformation.tx,
transformation.ty
);
try {
block();
} finally {
context.restore();
}
}
Added a bunch of utility methods to Points.
subtract
, scale
, equal
, and magnitude
.
Instance method transforamtions (scale, rotate, and translate) are now consistent with concatenation order.
var m1 = Matrix().translate(tx, ty).scale(s).rotate(theta);
var m2 = Matrix().concat(Matrix.translation(tx, ty)).concat(Matrix.scale(s)).concat(Matrix.rotation(theta));
matrixEqual(m1, m2);
This means that if you were using a version prior to 1.1.0 the order of concatenation has changed.
Added an optional aboutPoint
parameter to the scale instance and class methods.