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 // HASH=635d54b4716e226e93dfbc21ad40e77d
5 REG_FIDDLE(Canvas_drawPoints, 256, 200, false, 0) {
draw(SkCanvas * canvas)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
33