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(IPoint_add_operator, 256, 128, false, 0) {
draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) {
6 auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void {
7 for (size_t i = 0; i < count - 1; ++i) {
8 SkPoint p0, p1;
9 p0.iset(pts[i]);
10 p1.iset(pts[i + 1]);
11 canvas->drawLine(p0, p1, paint);
12 }
13 };
14 SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } };
15 SkPaint paint;
16 paint.setAntiAlias(true);
17 paint.setStyle(SkPaint::kStroke_Style);
18 canvas->scale(30, 15);
19 draw_lines(points, std::size(points), paint);
20 SkIPoint mod = {4, 1};
21 for (auto& point : points) {
22 point = point + mod;
23 mod.fX -= 1;
24 mod.fY += 1;
25 }
26 paint.setColor(SK_ColorRED);
27 draw_lines(points, std::size(points), paint);
28 }
29 } // END FIDDLE
30