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=e626e26bf557857b824aa7d03f723e0f
5cb93a386Sopenharmony_ciREG_FIDDLE(IPoint_subtract_operator, 256, 64, 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    points[1] += points[0] - points[3];
22cb93a386Sopenharmony_ci    points[2] -= points[1] - points[0];
23cb93a386Sopenharmony_ci    paint.setColor(SK_ColorRED);
24cb93a386Sopenharmony_ci    draw_lines(points, SK_ARRAY_COUNT(points), paint);
25cb93a386Sopenharmony_ci}
26cb93a386Sopenharmony_ci}  // END FIDDLE
27