skia2/docs/examples/checker_board.cpp
Mike Reed 1f60733fb3 Revert "Revert "move onto new factories for SkMatrix""
This reverts commit c80ee456ad.

fix: update flutter's gn file to add guard

Change-Id: Iac5171c8475d9a862d06255dab1c6f38f10de2f2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291361
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-05-21 16:58:39 +00:00

28 lines
894 B
C++

// Copyright 2020 Google LLC.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include "tools/fiddle/examples.h"
REG_FIDDLE(checker_board, 256, 256, false, 0) {
void checkerboard(SkCanvas* canvas) {
SkColor color1 = SK_ColorLTGRAY;
SkColor color2 = SK_ColorCYAN;
SkScalar scale = 10.0f;
SkPath path;
path.addRect(0, 0, scale, scale);
SkMatrix matrix = SkMatrix::Scale(2 * scale, scale);
matrix.preSkew(0.5f, 0);
SkPaint paint;
paint.setPathEffect(SkPath2DPathEffect::Make(matrix, path));
paint.setAntiAlias(true);
paint.setColor(color2);
canvas->clear(color1);
SkRect bounds = SkRect::MakeWH(256, 256);
bounds.outset(scale, scale);
canvas->drawRect(bounds, paint);
}
void draw(SkCanvas* canvas) {
canvas->drawColor(SK_ColorWHITE);
checkerboard(canvas);
}
} // END FIDDLE