blob: 42f27dbb805064df5def92bfc7197455c734ea31 [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001// 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.
Mike Kleinc0bd9f92019-04-23 12:05:21 -05003#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04004// HASH=3ba94448a4ba48f926e643baeb5b1016
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(Path_ConvertConicToQuads, 256, 256, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04006void draw(SkCanvas* canvas) {
7 SkPaint conicPaint;
8 conicPaint.setAntiAlias(true);
9 conicPaint.setStyle(SkPaint::kStroke_Style);
10 SkPaint quadPaint(conicPaint);
11 quadPaint.setColor(SK_ColorRED);
12 SkPoint conic[] = { {20, 170}, {80, 170}, {80, 230} };
13 for (auto weight : { .25f, .5f, .707f, .85f, 1.f } ) {
14 SkPoint quads[5];
15 SkPath::ConvertConicToQuads(conic[0], conic[1], conic[2], weight, quads, 1);
16 SkPath path;
17 path.moveTo(conic[0]);
18 path.conicTo(conic[1], conic[2], weight);
19 canvas->drawPath(path, conicPaint);
20 path.rewind();
21 path.moveTo(quads[0]);
22 path.quadTo(quads[1], quads[2]);
23 path.quadTo(quads[3], quads[4]);
24 canvas->drawPath(path, quadPaint);
25 canvas->translate(50, -50);
26 }
27}
28} // END FIDDLE