Flutter Engine
The Flutter Engine
convex_overstroke_linear_approx_curve.cpp
Go to the documentation of this file.
1// 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.
4REG_FIDDLE(convex_overstroke_linear_approx_curve, 256, 256, false, 0) {
5#include <math.h>
6
7void draw(SkCanvas* canvas) {
8 const float SCALE = 1;
9 const int WIDTH = 150;
10
11 const float PI = 3.1415926;
12
13 canvas->scale(SCALE, SCALE);
14 canvas->translate(50, 50);
15
16 SkPoint p1 = SkPoint::Make(50, 50);
17 SkPoint p2 = SkPoint::Make(80, 50);
18
19 SkPoint points[10];
20
21 for (int i = 0; i < 10; i++) {
22 points[i] = SkPoint::Make(65 + 15 * cos(i * PI / 10), 50 - 15 * sin(i * PI / 10));
23 }
24
26 path.moveTo(p1);
27 path.lineTo(p2);
28
29 for (int i = 0; i < 10; i++) {
30 path.lineTo(points[i]);
31 }
32 path.lineTo(p1);
33 // path.close();
34
35 SkPaint p;
36 p.setColor(SK_ColorRED);
37 p.setAntiAlias(true);
38 p.setStyle(SkPaint::kStroke_Style);
39 p.setStrokeWidth(WIDTH);
40
41 canvas->drawPath(path, p);
42
43 SkPath fillpath;
45
46 SkPaint fillp;
48 fillp.setAntiAlias(true);
50 fillp.setStrokeWidth(1);
51
52 canvas->drawPath(fillpath, fillp);
53}
54} // END FIDDLE
static const int points[]
#define PI
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
@ SCALE
Definition: SkPictureFlat.h:65
#define WIDTH
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void setStyle(Style style)
Definition: SkPaint.cpp:105
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
Definition: SkPath.h:59
REG_FIDDLE(convex_overstroke_linear_approx_curve, 256, 256, false, 0)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
SK_API bool FillPathWithPaint(const SkPath &src, const SkPaint &paint, SkPath *dst, const SkRect *cullRect, SkScalar resScale=1)
Definition: SkPathUtils.cpp:23
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173