If I use a transformation function like translate
/rotate
on a canvas, then all points are transformed when passed to any canvas function. This works like a charm, but is there also a way to simply get the transformed point without actually drawing?
This will be extremely helpful when debugging. All I can do now is looking where the point ends up, but I cannot seem to obtain the calculated transformed coordinates.
So, say I rotate 90 degrees, is there any function that takes a point (i.e. (10, 0)
) and gives the transformed point back (i.e. (0, 10)
)?
I basically mean something like this:
ctx.rotate(90 * Math.PI / 180);
ctx.transformed(10, 0); // would return (0, 10) as an array or something