Flutter Engine
The Flutter Engine
Matrix_preTranslate.cpp
Go to the documentation of this file.
1// Copyright 2019 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4REG_FIDDLE(Matrix_preTranslate, 256, 160, false, 0) {
5void draw(SkCanvas* canvas) {
7 paint.setAntiAlias(true);
8 SkRect rect = {20, 20, 100, 100};
9 for (int i = 0; i < 2; ++i ) {
11 i == 0 ? matrix.reset(): matrix.setRotate(25, rect.centerX(), 320);
12 {
13 SkAutoCanvasRestore acr(canvas, true);
14 canvas->concat(matrix);
15 paint.setColor(SK_ColorGRAY);
16 canvas->drawRect(rect, paint);
17 }
18 paint.setColor(SK_ColorRED);
19 for (int j = 0; j < 2; ++j ) {
20 SkAutoCanvasRestore acr(canvas, true);
21 matrix.preTranslate(40, 40);
22 canvas->concat(matrix);
23 canvas->drawCircle(0, 0, 3, paint);
24 }
25 }
26}
27} // END FIDDLE
REG_FIDDLE(Matrix_preTranslate, 256, 160, false, 0)
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Definition: SkCanvas.cpp:2707
const Paint & paint
Definition: color_source.cc:38
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350