A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/en-US/docs/Web/API/CanvasRenderingContext2D/transform below:

CanvasRenderingContext2D: transform() method - Web APIs

CanvasRenderingContext2D: transform() method

Baseline Widely available

The CanvasRenderingContext2D.transform() method of the Canvas 2D API multiplies the current transformation with the matrix described by the arguments of this method. This lets you scale, rotate, translate (move), and skew the context.

Note: See also the setTransform() method, which resets the current transform to the identity matrix and then invokes transform().

Syntax
transform(a, b, c, d, e, f)

The transformation matrix is described by: [ a c e b d f 0 0 1 ] \left[ \begin{array}{ccc} a & c & e \ b & d & f \ 0 & 0 & 1 \end{array} \right] .

Parameters
a (m11)

The cell in the first row and first column of the matrix.

b (m12)

The cell in the second row and first column of the matrix.

c (m21)

The cell in the first row and second column of the matrix.

d (m22)

The cell in the second row and second column of the matrix.

e (m41)

The cell in the first row and third column of the matrix.

f (m42)

The cell in the second row and third column of the matrix.

If a point originally had coordinates ( x , y ) (x, y) , then after the transformation it will have coordinates ( a x + c y + e , b x + d y + f ) (ax + cy + e, bx + dy + f) . This means:

Return value

None (undefined).

Examples Skewing a shape

This example skews a rectangle both vertically (.2) and horizontally (.8). Scaling and translation remain unchanged.

HTML
<canvas id="canvas"></canvas>
JavaScript
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");

ctx.transform(1, 0.2, 0.8, 1, 0, 0);
ctx.fillRect(0, 0, 100, 100);
Result Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4