Debian Codegraph @

docs/examples/FillPathWithPaint.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(FillPathWithPaint, 256, 192, false, 0) {
5 void draw(SkCanvas* canvas) {
6 SkPaint strokePaint;
7 strokePaint.setAntiAlias(true);
8 strokePaint.setStyle(SkPaint::kStroke_Style);
9 strokePaint.setStrokeWidth(.1f);
10 SkPath strokePath = SkPathBuilder()
11 .moveTo(.08f, .08f)
12 .quadTo(.09f, .08f, .17f, .17f)
13 .detach();
14 SkPathBuilder fillPath;
15 SkPaint outlinePaint(strokePaint);
16 outlinePaint.setStrokeWidth(2);
17 SkMatrix scale = SkMatrix::Scale(300, 300);
18 for (SkScalar precision : { 0.01f, .1f, 1.f, 10.f, 100.f } ) {
19 skpathutils::FillPathWithPaint(strokePath, strokePaint, &fillPath, nullptr,
20 SkMatrix::Scale(precision, precision));
21 fillPath.transform(scale);
22 canvas->drawPath(fillPath.detach(), outlinePaint);
23 canvas->translate(60, 0);
24 if (1.f == precision) canvas->translate(-180, 100);
25 }
26 strokePath = strokePath.makeTransform(scale);
27 strokePaint.setStrokeWidth(30);
28 canvas->drawPath(strokePath, strokePaint);
29 }
30 } // END FIDDLE