blob: 95dafc4b47bb00046bf031b63878f8e8aa47d342 [file] [log] [blame]
Hal Canary6c8422c2020-01-10 15:22:09 -05001// 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"
4REG_FIDDLE(checker_board, 256, 256, false, 0) {
5void 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);
Mike Reed1f607332020-05-21 12:11:27 -040011 SkMatrix matrix = SkMatrix::Scale(2 * scale, scale);
Hal Canary6c8422c2020-01-10 15:22:09 -050012 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
23void draw(SkCanvas* canvas) {
24 canvas->drawColor(SK_ColorWHITE);
25 checkerboard(canvas);
26}
27} // END FIDDLE