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=635d54b4716e226e93dfbc21ad40e77d |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 5 | REG_FIDDLE(Canvas_drawPoints, 256, 200, false, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 6 | void draw(SkCanvas* canvas) { |
| 7 | SkPaint paint; |
| 8 | paint.setAntiAlias(true); |
| 9 | paint.setStyle(SkPaint::kStroke_Style); |
| 10 | paint.setStrokeWidth(10); |
| 11 | paint.setColor(0x80349a45); |
| 12 | const SkPoint points[] = {{32, 16}, {48, 48}, {16, 32}}; |
| 13 | const SkPaint::Join join[] = { SkPaint::kRound_Join, |
| 14 | SkPaint::kMiter_Join, |
| 15 | SkPaint::kBevel_Join }; |
| 16 | int joinIndex = 0; |
| 17 | SkPath path; |
| 18 | path.addPoly(points, 3, false); |
| 19 | for (const auto cap : { SkPaint::kRound_Cap, SkPaint::kSquare_Cap, SkPaint::kButt_Cap } ) { |
| 20 | paint.setStrokeCap(cap); |
| 21 | paint.setStrokeJoin(join[joinIndex++]); |
| 22 | for (const auto mode : { SkCanvas::kPoints_PointMode, |
| 23 | SkCanvas::kLines_PointMode, |
| 24 | SkCanvas::kPolygon_PointMode } ) { |
| 25 | canvas->drawPoints(mode, 3, points, paint); |
| 26 | canvas->translate(64, 0); |
| 27 | } |
| 28 | canvas->drawPath(path, paint); |
| 29 | canvas->translate(-192, 64); |
| 30 | } |
| 31 | } |
| 32 | } // END FIDDLE |