Flutter Engine
The Flutter Engine
Functions | Variables
largeclippedpath.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkPath.h"

Go to the source code of this file.

Functions

static void draw_clipped_flower (SkCanvas *canvas, SkPathFillType fillType)
 
 DEF_SIMPLE_GM (largeclippedpath_winding, canvas, kSize, kSize)
 
 DEF_SIMPLE_GM (largeclippedpath_evenodd, canvas, kSize, kSize)
 

Variables

constexpr int kSize = 1000
 

Function Documentation

◆ DEF_SIMPLE_GM() [1/2]

DEF_SIMPLE_GM ( largeclippedpath_evenodd  ,
canvas  ,
kSize  ,
kSize   
)

Definition at line 52 of file largeclippedpath.cpp.

52 {
54}
static void draw_clipped_flower(SkCanvas *canvas, SkPathFillType fillType)

◆ DEF_SIMPLE_GM() [2/2]

DEF_SIMPLE_GM ( largeclippedpath_winding  ,
canvas  ,
kSize  ,
kSize   
)

Definition at line 48 of file largeclippedpath.cpp.

◆ draw_clipped_flower()

static void draw_clipped_flower ( SkCanvas canvas,
SkPathFillType  fillType 
)
static

Definition at line 16 of file largeclippedpath.cpp.

16 {
17 canvas->clear(SK_ColorCYAN);
20 constexpr static int kGridCount = 50;
21 constexpr static float kCellSize = (float)kSize / kGridCount;
22 for (int y = 0; y < kGridCount; ++y) {
23 clip.addRect(0, y * kCellSize, kSize, (y + 1) * kCellSize, SkPathDirection(y & 1));
24 }
25 for (int x = 0; x < kGridCount; ++x) {
26 clip.addRect(x * kCellSize, 0, (x + 1) * kCellSize, kSize, SkPathDirection(x & 1));
27 }
28 canvas->clipPath(clip);
30 flower.setFillType(fillType);
31 flower.moveTo(1, 0);
32 constexpr static int kNumPetals = 9;
33 for (int i = 1; i <= kNumPetals; ++i) {
34 float c = 2*SK_ScalarPI*(i - .5f) / kNumPetals;
35 float theta = 2*SK_ScalarPI*i / kNumPetals;
36 flower.quadTo(cosf(c)*2, sinf(c)*2, cosf(theta), sinf(theta));
37 }
38 flower.close();
39 flower.addArc(SkRect::MakeLTRB(-.75f, -.75f, .75f, .75f), 0, 360);
40 canvas->translate(kSize/2.f, kSize/2.f);
41 canvas->scale(kSize/3.f, kSize/3.f);
42 SkPaint p;
43 p.setAntiAlias(true);
44 p.setColor(SK_ColorMAGENTA);
45 canvas->drawPath(flower, p);
46}
constexpr SkColor SK_ColorMAGENTA
Definition: SkColor.h:147
constexpr SkColor SK_ColorCYAN
Definition: SkColor.h:143
SkPathDirection
Definition: SkPathTypes.h:34
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
#define SK_ScalarPI
Definition: SkScalar.h:21
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void clear(SkColor color)
Definition: SkCanvas.h:1199
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1456
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
Definition: SkPath.h:59
void setFillType(SkPathFillType ft)
Definition: SkPath.h:235
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
Definition: SkPath.cpp:864
static void flower(SkCanvas *canvas, const SkPath &path, SkScalar intervals[2], SkPaint::Join join)
Definition: dashcubics.cpp:32
const int kCellSize
constexpr int kSize
double y
double x
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646

Variable Documentation

◆ kSize

constexpr int kSize = 1000
constexpr

Definition at line 12 of file largeclippedpath.cpp.