Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Paint_setStyle.cpp
Go to the documentation of this file.
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.
4// HASH=c7bb6248e4735b8d1a32d02fba40d344
5REG_FIDDLE(Paint_setStyle, 256, 256, false, 0) {
6void draw(SkCanvas* canvas) {
8 paint.setStrokeWidth(5);
9 SkRegion region;
10 region.op({140, 10, 160, 30}, SkRegion::kUnion_Op);
11 region.op({170, 40, 190, 60}, SkRegion::kUnion_Op);
13 bitmap.setInfo(SkImageInfo::MakeA8(50, 50), 50);
14 uint8_t pixels[50][50];
15 for (int x = 0; x < 50; ++x) {
16 for (int y = 0; y < 50; ++y) {
17 pixels[y][x] = (x + y) % 5 ? 0xFF : 0x00;
18 }
19 }
20 bitmap.setPixels(pixels);
21 for (auto style : { SkPaint::kFill_Style,
24 paint.setStyle(style);
25 canvas->drawLine(10, 10, 60, 60, paint);
26 canvas->drawRect({80, 10, 130, 60}, paint);
27 canvas->drawRegion(region, paint);
28 canvas->drawImage(bitmap.asImage(), 200, 10, SkSamplingOptions(), &paint);
29 canvas->translate(0, 80);
30 }
31}
32} // END FIDDLE
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
void drawRegion(const SkRegion &region, const SkPaint &paint)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition SkCanvas.h:1528
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
@ kFill_Style
set to fill geometry
Definition SkPaint.h:193
@ kStrokeAndFill_Style
sets to stroke and fill geometry
Definition SkPaint.h:195
@ kUnion_Op
target unioned with operand
Definition SkRegion.h:369
bool op(const SkIRect &rect, Op op)
Definition SkRegion.h:384
const Paint & paint
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition examples.h:60
double y
double x
static SkImageInfo MakeA8(int width, int height)