Flutter Engine
The Flutter Engine
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.
4REG_FIDDLE(Paint_setStyle, 256, 256, false, 0) {
5void draw(SkCanvas* canvas) {
7 paint.setStrokeWidth(5);
9 region.op({140, 10, 160, 30}, SkRegion::kUnion_Op);
10 region.op({170, 40, 190, 60}, SkRegion::kUnion_Op);
12 bitmap.setInfo(SkImageInfo::MakeA8(50, 50), 50);
13 uint8_t pixels[50][50];
14 for (int x = 0; x < 50; ++x) {
15 for (int y = 0; y < 50; ++y) {
16 pixels[y][x] = (x + y) % 5 ? 0xFF : 0x00;
17 }
18 }
19 bitmap.setPixels(pixels);
20 for (auto style : { SkPaint::kFill_Style,
23 paint.setStyle(style);
24 canvas->drawLine(10, 10, 60, 60, paint);
25 canvas->drawRect({80, 10, 130, 60}, paint);
26 canvas->drawRegion(region, paint);
27 canvas->drawImage(bitmap.asImage(), 200, 10, SkSamplingOptions(), &paint);
28 canvas->translate(0, 80);
29 }
30}
31} // END FIDDLE
REG_FIDDLE(Paint_setStyle, 256, 256, false, 0)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
Definition: SkCanvas.cpp:2700
void drawRegion(const SkRegion &region, const SkPaint &paint)
Definition: SkCanvas.cpp:1685
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
Definition: color_source.cc:38
double y
double x
ClipOpAndAA opAA SkRegion region
Definition: SkRecords.h:238
Definition: bitmap.py:1
SkSamplingOptions(SkFilterMode::kLinear))
static SkImageInfo MakeA8(int width, int height)