blob: 0206b5c7b579c751ae5cb8263e96a60ac80fc5d8 [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001// 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 Kleinc0bd9f92019-04-23 12:05:21 -05003#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04004// HASH=635d54b4716e226e93dfbc21ad40e77d
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(Canvas_drawPoints, 256, 200, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04006void 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