Debian Codegraph @

docs/examples/Paint_setStyle.cpp

raw
1 // Copyright 2019 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(Paint_setStyle, 256, 256, false, 0) {
5 void draw(SkCanvas* canvas) {
6 SkPaint paint;
7 paint.setStrokeWidth(5);
8 SkRegion region;
9 region.op({140, 10, 160, 30}, SkRegion::kUnion_Op);
10 region.op({170, 40, 190, 60}, SkRegion::kUnion_Op);
11 SkBitmap bitmap;
12 uint8_t pixels[50][50];
13 for (int x = 0; x < 50; ++x) {
14 for (int y = 0; y < 50; ++y) {
15 pixels[y][x] = (x + y) % 5 ? 0xFF : 0x00;
16 }
17 }
18 bitmap.installPixels(SkImageInfo::MakeA8(50, 50), pixels, 50);
19 for (auto style : { SkPaint::kFill_Style,
20 SkPaint::kStroke_Style,
21 SkPaint::kStrokeAndFill_Style }) {
22 paint.setStyle(style);
23 canvas->drawLine(10, 10, 60, 60, paint);
24 canvas->drawRect({80, 10, 130, 60}, paint);
25 canvas->drawRegion(region, paint);
26 canvas->drawImage(bitmap.asImage(), 200, 10, SkSamplingOptions(), &paint);
27 canvas->translate(0, 80);
28 }
29 }
30 } // END FIDDLE