1cb93a386Sopenharmony_ci// Copyright 2019 Google LLC.
2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h"
4cb93a386Sopenharmony_ci// HASH=63f4cba971c6d8434595906f865b5a29
5cb93a386Sopenharmony_ciREG_FIDDLE(IPoint_add_operator, 256, 128, false, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void {
8cb93a386Sopenharmony_ci        for (size_t i = 0; i < count - 1; ++i) {
9cb93a386Sopenharmony_ci            SkPoint p0, p1;
10cb93a386Sopenharmony_ci            p0.iset(pts[i]);
11cb93a386Sopenharmony_ci            p1.iset(pts[i + 1]);
12cb93a386Sopenharmony_ci            canvas->drawLine(p0, p1, paint);
13cb93a386Sopenharmony_ci        }
14cb93a386Sopenharmony_ci    };
15cb93a386Sopenharmony_ci    SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } };
16cb93a386Sopenharmony_ci    SkPaint paint;
17cb93a386Sopenharmony_ci    paint.setAntiAlias(true);
18cb93a386Sopenharmony_ci    paint.setStyle(SkPaint::kStroke_Style);
19cb93a386Sopenharmony_ci    canvas->scale(30, 15);
20cb93a386Sopenharmony_ci    draw_lines(points, SK_ARRAY_COUNT(points), paint);
21cb93a386Sopenharmony_ci    SkIPoint mod = {4, 1};
22cb93a386Sopenharmony_ci    for (auto& point : points) {
23cb93a386Sopenharmony_ci        point = point + mod;
24cb93a386Sopenharmony_ci        mod.fX -= 1;
25cb93a386Sopenharmony_ci        mod.fY += 1;
26cb93a386Sopenharmony_ci    }
27cb93a386Sopenharmony_ci    paint.setColor(SK_ColorRED);
28cb93a386Sopenharmony_ci    draw_lines(points, SK_ARRAY_COUNT(points), paint);
29cb93a386Sopenharmony_ci}
30cb93a386Sopenharmony_ci}  // END FIDDLE
31