Flutter Engine
The Flutter Engine
fivearcs.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(fivearcs, 256, 128, false, 0) {
5void draw(SkCanvas* canvas) {
6 canvas->clear(SkColorSetARGB(255, 255, 255, 255));
7 SkPaint ovalPaint;
8 ovalPaint.setAntiAlias(true);
10 SkPaint arcPaint(ovalPaint);
11 arcPaint.setStrokeWidth(5);
12 arcPaint.setColor(SK_ColorBLUE);
13 SkRect oval = {8, 8, 56, 56};
14
15 canvas->drawOval(oval, ovalPaint);
16 SkPath arcPath;
17 arcPath.arcTo(oval, 0, 90, false);
18 canvas->drawPath(arcPath, arcPaint);
19
20 canvas->translate(64, 0);
21 canvas->drawOval(oval, ovalPaint);
22 canvas->drawArc(oval, 0, 90, false, arcPaint);
23
24 canvas->translate(64, 0);
25 canvas->drawOval(oval, ovalPaint);
26 arcPath.reset();
27 arcPath.addArc(oval, 0, 90);
28 canvas->drawPath(arcPath, arcPaint);
29
30 canvas->translate(-96, 64);
31 canvas->drawOval(oval, ovalPaint);
32 arcPath.reset();
33 arcPath.moveTo({56, 32});
34 arcPath.arcTo({56, 56}, {32, 56}, 24);
35 canvas->drawPath(arcPath, arcPaint);
36
37 canvas->translate(64, 0);
38 canvas->drawOval(oval, ovalPaint);
39 arcPath.reset();
40 arcPath.moveTo({56, 32});
41 arcPath.arcTo({24, 24}, 0, SkPath::kSmall_ArcSize, SkPathDirection::kCW, {32, 56});
42 canvas->drawPath(arcPath, arcPaint);
43}
44} // END FIDDLE
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColor.h:49
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawOval(const SkRect &oval, const SkPaint &paint)
Definition: SkCanvas.cpp:1698
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void clear(SkColor color)
Definition: SkCanvas.h:1199
void drawArc(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint)
Definition: SkCanvas.cpp:2728
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
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
SkPath & arcTo(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo)
Definition: SkPath.cpp:1220
SkPath & moveTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:688
SkPath & addArc(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle)
Definition: SkPath.cpp:1439
@ kSmall_ArcSize
smaller of arc pair
Definition: SkPath.h:924
SkPath & reset()
Definition: SkPath.cpp:370
REG_FIDDLE(fivearcs, 256, 128, false, 0)
Definition: fivearcs.cpp:4
SkRect oval
Definition: SkRecords.h:249