Promotic
WikipediaLinkedInYoutubeTwitterFacebook

setTransform - method of object CanvasCtx

Description:
Resets the current transform to another matrix. Then runs transform().
Syntax:
setTransform(a As Long, b As Long, c As Long, d As Long, e As Long, f As Long) As Object
Calling:
ctx.setTransform(a, b, c, d, e, f);
Parameters:
a(Long) Horizontal drawing ratio
b(Long) Horizontal drawing skew
c(Long) Vertical drawing skew
d(Long) Vertical drawing skew ratio
e(Long) Horizontal drawing shift
f(Long) Vertical drawing shift
Note:
The transformation allows to map the positions from one co-ordinate system to another. It can be used for drawing a shape into a magnified/reduced, rotated, shifted, mirrored 2D space. It is easier to transform the 2D space co-ordinates than recalculating the co-ordinates of all objects. All position stransformations are defined by 6 variables a, b, c, d, e, f (out of 9) of the 2D space transformation matrix. The default value of non-transformed 2D space is 1, 0, 0, 1, 0, 0 (unit matrix). The transformation matrix is included in the drawing area. The save and restore methods can save this matrix.

The transformation methods transform, translate, scale or rotate modify some (or all) values of the transformation matrix. Each method saves the current state of the transformation matrix and then applies the modification(s). I.e. these modifications are cumulative.

By contrast, the setTransform transformation method first sets the currently valid transformation matrix to the default value and then executes the transform transformation. This makes it the only transformation method that cen reset all cumulated transformations and set new transformation that is not cumulated.

See also:
Example:
ctx.fillStyle = "yellow";
ctx.fillRect(0, 0, 250, 100);
ctx.setTransform(1, 0.5, -0.5, 1, 30, 10);
ctx.fillStyle = "red";
ctx.fillRect(0, 0, 250, 100);
ctx.setTransform(1, 0.5, -0.5, 1, 30, 10);
ctx.fillStyle = "blue";
ctx.fillRect(0, 0, 250, 100);
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice