Programming Language: C++ (Cpp)

Class/Type: SkCanvas

Method/Function: concat

Examples at hotexamples.com: 23

SkCanvas::concat() is a method used in the Skia graphics library to concatenate a matrix with the current transformation matrix used by a SkCanvas object. This allows for transformations like scaling, translation, and rotation to be applied to drawings on the canvas.

Here are some code examples showing how to use SkCanvas::concat():

**Example 1:**

In this example, we create a SkCanvas object and a SkMatrix object called matrix. We then set the scale of the matrix to (2.0f, 2.0f) using the setScale() method. Finally, we concatenate the matrix with the canvas using SkCanvas::concat(), which scales the drawing by a factor of 2.

**Example 2:**

Here are some code examples showing how to use SkCanvas::concat():

SkCanvas canvas; SkMatrix matrix; matrix.setScale(2.0f, 2.0f); canvas.concat(matrix); // scales drawing by a factor of 2

In this example, we create a SkCanvas object and a SkMatrix object called matrix. We then set the scale of the matrix to (2.0f, 2.0f) using the setScale() method. Finally, we concatenate the matrix with the canvas using SkCanvas::concat(), which scales the drawing by a factor of 2.

SkCanvas canvas; SkMatrix matrix; matrix.setRotate(45.0f); canvas.concat(matrix); // rotates drawing by 45 degreesIn this example, we create a SkCanvas object and a SkMatrix object called matrix. We then set the rotation of the matrix to 45 degrees using the setRotate() method. Finally, we concatenate the matrix with the canvas using SkCanvas::concat(), which rotates the drawing by 45 degrees. These examples use the Skia graphics library, which is typically included in Android applications but can also be used in desktop applications.

Frequently Used Methods

Frequently Used Methods