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.
3 #include "tools/fiddle/examples.h"
4 REG_FIDDLE(Matrix_preTranslate, 256, 160, false, 0) {
draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) {
6 SkPaint paint;
7 paint.setAntiAlias(true);
8 SkRect rect = {20, 20, 100, 100};
9 for (int i = 0; i < 2; ++i ) {
10 SkMatrix matrix;
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
28