1 // Copyright 2020 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(checker_board, 256, 256, false, 0) {
checkerboard(SkCanvas * canvas)5 void checkerboard(SkCanvas* canvas) {
6 SkColor color1 = SK_ColorLTGRAY;
7 SkColor color2 = SK_ColorCYAN;
8 SkScalar scale = 10.0f;
9 SkPath path;
10 path.addRect(0, 0, scale, scale);
11 SkMatrix matrix = SkMatrix::Scale(2 * scale, scale);
12 matrix.preSkew(0.5f, 0);
13 SkPaint paint;
14 paint.setPathEffect(SkPath2DPathEffect::Make(matrix, path));
15 paint.setAntiAlias(true);
16 paint.setColor(color2);
17 canvas->clear(color1);
18 SkRect bounds = SkRect::MakeWH(256, 256);
19 bounds.outset(scale, scale);
20 canvas->drawRect(bounds, paint);
21 }
22
draw(SkCanvas * canvas)23 void draw(SkCanvas* canvas) {
24 canvas->drawColor(SK_ColorWHITE);
25 checkerboard(canvas);
26 }
27 } // END FIDDLE
28