blob: 424ce4f922d7579fa905dc92d1d5daea1d856e57 [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);
11 SkMatrix matrix = SkMatrix::MakeScale(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
23void draw(SkCanvas* canvas) {
24 canvas->drawColor(SK_ColorWHITE);
25 checkerboard(canvas);
26}
27} // END FIDDLE