1cb93a386Sopenharmony_ci// Copyright 2020 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_ciREG_FIDDLE(SkPath_quadTo_example, 512, 512, false, 0) {
5cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
6cb93a386Sopenharmony_ci    canvas->clear(SkColorSetARGB(255, 255, 255, 255));
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci    SkPaint paint;
9cb93a386Sopenharmony_ci    paint.setAntiAlias(true);
10cb93a386Sopenharmony_ci    paint.setStyle(SkPaint::kStroke_Style);
11cb93a386Sopenharmony_ci    paint.setStrokeWidth(5);
12cb93a386Sopenharmony_ci
13cb93a386Sopenharmony_ci    SkPoint a{100, 100};
14cb93a386Sopenharmony_ci    SkPoint b{200, 400};
15cb93a386Sopenharmony_ci    SkPoint c{300, 100};
16cb93a386Sopenharmony_ci
17cb93a386Sopenharmony_ci    SkPath twoSegments;
18cb93a386Sopenharmony_ci    twoSegments.moveTo(a);
19cb93a386Sopenharmony_ci    twoSegments.lineTo(b);
20cb93a386Sopenharmony_ci    twoSegments.lineTo(c);
21cb93a386Sopenharmony_ci
22cb93a386Sopenharmony_ci    canvas->drawPath(twoSegments, paint);
23cb93a386Sopenharmony_ci
24cb93a386Sopenharmony_ci    paint.setColor(SkColorSetARGB(255, 0, 0, 255));
25cb93a386Sopenharmony_ci    SkPath quadraticCurve;
26cb93a386Sopenharmony_ci    quadraticCurve.moveTo(a);
27cb93a386Sopenharmony_ci    quadraticCurve.quadTo(b, c);
28cb93a386Sopenharmony_ci    canvas->drawPath(quadraticCurve, paint);
29cb93a386Sopenharmony_ci
30cb93a386Sopenharmony_ci    SkFont font(nullptr, 32);
31cb93a386Sopenharmony_ci    SkPaint textPaint;
32cb93a386Sopenharmony_ci    textPaint.setAntiAlias(true);
33cb93a386Sopenharmony_ci    canvas->drawString("a", a.x(), a.y(), font, textPaint);
34cb93a386Sopenharmony_ci    canvas->drawString("b", b.x() + 20, b.y() + 20, font, textPaint);
35cb93a386Sopenharmony_ci    canvas->drawString("c", c.x(), c.y(), font, textPaint);
36cb93a386Sopenharmony_ci}
37cb93a386Sopenharmony_ci}  // END FIDDLE
38