• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // HASH=3ba94448a4ba48f926e643baeb5b1016
5 REG_FIDDLE(Path_ConvertConicToQuads, 256, 256, false, 0) {
draw(SkCanvas * canvas)6 void 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
29