Flutter Engine
The Flutter Engine
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
REG_FIDDLE(FillPathWithPaint, 256, 192, false, 0)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
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
Definition: SkPath.h:59
void transform(const SkMatrix &matrix, SkPath *dst, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
Definition: SkPath.cpp:1711
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)
Definition: SkPathUtils.cpp:23
const Scalar scale