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