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