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