| 1 |
// 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. |
| 3 |
#include "tools/fiddle/examples.h" |
| 4 |
REG_FIDDLE(Path_ConvertConicToQuads, 256, 256, false, 0) { |
| 5 |
void draw(SkCanvas* canvas) { |
| 6 |
SkPaint conicPaint; |
| 7 |
conicPaint.setAntiAlias(true); |
| 8 |
conicPaint.setStyle(SkPaint::kStroke_Style); |
| 9 |
SkPaint quadPaint(conicPaint); |
| 10 |
quadPaint.setColor(SK_ColorRED); |
| 11 |
SkPoint conic[] = { {20, 170}, {80, 170}, {80, 230} }; |
| 12 |
for (auto weight : { .25f, .5f, .707f, .85f, 1.f } ) { |
| 13 |
SkPoint quads[5]; |
| 14 |
SkPath::ConvertConicToQuads(conic[0], conic[1], conic[2], weight, quads, 1); |
| 15 |
SkPath path = SkPathBuilder() |
| 16 |
.moveTo(conic[0]) |
| 17 |
.conicTo(conic[1], conic[2], weight) |
| 18 |
.detach(); |
| 19 |
canvas->drawPath(path, conicPaint); |
| 20 |
path = SkPathBuilder() |
| 21 |
.moveTo(quads[0]) |
| 22 |
.quadTo(quads[1], quads[2]) |
| 23 |
.quadTo(quads[3], quads[4]) |
| 24 |
.detach(); |
| 25 |
canvas->drawPath(path, quadPaint); |
| 26 |
canvas->translate(50, -50); |
| 27 |
} |
| 28 |
} |
| 29 |
} // END FIDDLE |