Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
FillPathWithPaint.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(FillPathWithPaint, 256, 192, false, 0) {
5void draw(SkCanvas* canvas) {
6 SkPaint strokePaint;
7 strokePaint.setAntiAlias(true);
9 strokePaint.setStrokeWidth(.1f);
11 strokePath.moveTo(.08f, .08f);
12 strokePath.quadTo(.09f, .08f, .17f, .17f);
13 SkPath fillPath;
14 SkPaint outlinePaint(strokePaint);
15 outlinePaint.setStrokeWidth(2);
16 SkMatrix scale = SkMatrix::Scale(300, 300);
17 for (SkScalar precision : { 0.01f, .1f, 1.f, 10.f, 100.f } ) {
18 skpathutils::FillPathWithPaint(strokePath, strokePaint, &fillPath, nullptr, precision);
19 fillPath.transform(scale);
20 canvas->drawPath(fillPath, outlinePaint);
21 canvas->translate(60, 0);
22 if (1.f == precision) canvas->translate(-180, 100);
23 }
24 strokePath.transform(scale);
25 strokePaint.setStrokeWidth(30);
26 canvas->drawPath(strokePath, strokePaint);
27}
28} // END FIDDLE
bool FillPathWithPaint(const SkPath &src, const SkPaint &paint, SkPath *dst, const SkRect *cullRect, SkScalar resScale)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void translate(SkScalar dx, SkScalar dy)
void drawPath(const SkPath &path, const SkPaint &paint)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
Definition SkMatrix.h:75
void setStyle(Style style)
Definition SkPaint.cpp:105
void setAntiAlias(bool aa)
Definition SkPaint.h:170
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
void setStrokeWidth(SkScalar width)
Definition SkPaint.cpp:159
SkPath & moveTo(SkScalar x, SkScalar y)
Definition SkPath.cpp:678
SkPath & quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
Definition SkPath.cpp:736
void transform(const SkMatrix &matrix, SkPath *dst, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
Definition SkPath.cpp:1647
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition examples.h:60
float SkScalar
Definition extension.cpp:12
static void strokePath(SkCanvas *canvas, const SkPath &path)
SK_API bool FillPathWithPaint(const SkPath &src, const SkPaint &paint, SkPath *dst, const SkRect *cullRect, SkScalar resScale=1)
const Scalar scale