Debian Codegraph @

docs/examples/Canvas_drawPoints.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(Canvas_drawPoints, 256, 200, false, 0) {
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 = SkPath::Polygon(points, false);
17 for (const auto cap : { SkPaint::kRound_Cap, SkPaint::kSquare_Cap, SkPaint::kButt_Cap } ) {
18 paint.setStrokeCap(cap);
19 paint.setStrokeJoin(join[joinIndex++]);
20 for (const auto mode : { SkCanvas::kPoints_PointMode,
21 SkCanvas::kLines_PointMode,
22 SkCanvas::kPolygon_PointMode } ) {
23 canvas->drawPoints(mode, points, paint);
24 canvas->translate(64, 0);
25 }
26 canvas->drawPath(path, paint);
27 canvas->translate(-192, 64);
28 }
29 }
30 } // END FIDDLE