33 this->
reset(anchorPt);
38 fLastPt = fAnchorPt = anchorPt;
42 if (numSubdivisions <= 0) {
50 float T = this->chooseChopT(numSubdivisions);
54 SkPoint midpt = fLastPt * (1 -
T) + pt *
T;
55 this->
sliceLine(midpt, numSubdivisions - 1);
60 if (numSubdivisions <= 0) {
68 float T = this->chooseChopT(numSubdivisions);
80 if (numSubdivisions <= 0) {
88 float T = this->chooseChopT(numSubdivisions);
99 if (numSubdivisions <= 0) {
107 float T = this->chooseChopT(numSubdivisions);
112 if (!
conic.chopAt(
T, halves)) {
115 this->
sliceConic(halves[0].
fPts[1], halves[0].
fPts[2], halves[0].fW, numSubdivisions - 1);
116 this->
sliceConic(halves[1].
fPts[1], halves[1].
fPts[2], halves[1].fW, numSubdivisions - 1);
122 float chooseChopT(
int numSubdivisions) {
124 if (numSubdivisions > 1) {
127 float T = (0 == fRand.
nextU() % 10) ? 0 : scalbnf(1, -(
int)fRand.
nextRangeU(10, 149));
152 paint.setAntiAlias(
true);
155 mandoline.
sliceCubic({5, 277}, {381, -74}, {243, 162});
156 mandoline.sliceLine({41, 43});
159 mandoline.reset({357.049988f, 446.049988f});
160 mandoline.sliceCubic({472.750000f, -71.950012f}, {639.750000f, 531.950012f},
161 {309.049988f, 347.950012f});
162 mandoline.sliceLine({309.049988f, 419});
163 mandoline.sliceLine({357.049988f, 446.049988f});
168 canvas->
scale(100, 81);
170 mandoline.sliceConic({-2, 0},
174 mandoline.sliceLine({0, 0});
181 canvas->
scale(75, 75);
182 mandoline.reset({1, 0});
183 constexpr int nquads = 5;
184 for (
int i = 0;
i < nquads; ++
i) {
187 mandoline.sliceQuadratic({cosf(theta1)*2, sinf(theta1)*2},
188 {cosf(theta2), sinf(theta2)});
195DEF_GM(
return new SliverPathsGM;)
#define SK_ABORT(message,...)
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorWHITE
void SkChopQuadAt(const SkPoint src[3], SkPoint dst[5], SkScalar t)
void SkChopCubicAt(const SkPoint src[4], SkPoint dst[7], SkScalar t)
#define SkDegreesToRadians(degrees)
void translate(SkScalar dx, SkScalar dy)
void drawPath(const SkPath &path, const SkPaint &paint)
void scale(SkScalar sx, SkScalar sy)
SkPath & moveTo(SkScalar x, SkScalar y)
void setFillType(SkPathFillType ft)
SkPath & lineTo(SkScalar x, SkScalar y)
SkPath & setIsVolatile(bool isVolatile)
SkPath & quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
SkPath & cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
SkPath & conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
uint32_t nextRangeU(uint32_t min, uint32_t max)
const SkPath & path() const
static constexpr int kDefaultSubdivisions
void sliceQuadratic(SkPoint p1, SkPoint p2, int numSubdivisions=kDefaultSubdivisions)
void reset(SkPoint anchorPt)
MandolineSlicer(SkPoint anchorPt)
void sliceConic(SkPoint p1, SkPoint p2, float w, int numSubdivisions=kDefaultSubdivisions)
void sliceCubic(SkPoint p1, SkPoint p2, SkPoint p3, int numSubdivisions=kDefaultSubdivisions)
void sliceLine(SkPoint pt, int numSubdivisions=kDefaultSubdivisions)
void onDraw(SkCanvas *canvas) override
SkString getName() const override
SkISize getISize() override
DEF_GM(return F(C(clipbox), 0.0f, 0.0f, {})) DEF_GM(return F(C(clipbox)
static constexpr SkISize Make(int32_t w, int32_t h)