Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 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. |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 3 | #include "tools/fiddle/examples.h" |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 4 | // HASH=cedd6233848198e1fca4d1e14816baaf |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 5 | REG_FIDDLE(Paint_getFillPath, 256, 192, false, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 6 | void draw(SkCanvas* canvas) { |
| 7 | SkPaint strokePaint; |
| 8 | strokePaint.setAntiAlias(true); |
| 9 | strokePaint.setStyle(SkPaint::kStroke_Style); |
| 10 | strokePaint.setStrokeWidth(.1f); |
| 11 | SkPath strokePath; |
| 12 | strokePath.moveTo(.08f, .08f); |
| 13 | strokePath.quadTo(.09f, .08f, .17f, .17f); |
| 14 | SkPath fillPath; |
| 15 | SkPaint outlinePaint(strokePaint); |
| 16 | outlinePaint.setStrokeWidth(2); |
Mike Reed | 1f60733 | 2020-05-21 12:11:27 -0400 | [diff] [blame] | 17 | SkMatrix scale = SkMatrix::Scale(300, 300); |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 18 | for (SkScalar precision : { 0.01f, .1f, 1.f, 10.f, 100.f } ) { |
| 19 | strokePaint.getFillPath(strokePath, &fillPath, nullptr, precision); |
| 20 | fillPath.transform(scale); |
| 21 | canvas->drawPath(fillPath, outlinePaint); |
| 22 | canvas->translate(60, 0); |
| 23 | if (1.f == precision) canvas->translate(-180, 100); |
| 24 | } |
| 25 | strokePath.transform(scale); |
| 26 | strokePaint.setStrokeWidth(30); |
| 27 | canvas->drawPath(strokePath, strokePaint); |
| 28 | } |
| 29 | } // END FIDDLE |