Options
These globals are now defined:
double duration; // The requested duration of the animation. double frame; // A value in [0, 1] of where we are in the animation.
This global is now defined:
GrBackendRenderTarget backEndRenderTarget;
GrBackendTexture backEndTextureRenderTarget;
Optional source image
These globals are now defined:
SkBitmap source; sk_sp<SkImage> image; GrBackendTexture backEndTexture; // GPU Only.
Note:
Adding comments with SK_FOLD_START and SK_FOLD_END creates
foldable code blocks.
These blocks will be folded by default and are useful for highlighting specific lines of code.
You can also use the keyboard shortcuts Ctrl+S and Ctrl+E in the code editor to set them.
These blocks will be folded by default and are useful for highlighting specific lines of code.
You can also use the keyboard shortcuts Ctrl+S and Ctrl+E in the code editor to set them.
xxxxxxxxxx
36
void draw(SkCanvas* canvas) {
SkScalar width = 300;
SkScalar height = 100;
SkScalar radii[4] { 64, 16, 48, 8 };
SkScalar startAngles[4] { -180, -90, 0, 90 };
SkRect corners[4] {
SkRect::MakeXYWH(0, 0, radii[0]*2, radii[0]*2),
SkRect::MakeXYWH(width-radii[1]*2, 0, radii[1]*2, radii[1]*2),
SkRect::MakeXYWH(width-radii[2]*2, height-radii[2]*2, radii[2]*2, radii[2]*2),
SkRect::MakeXYWH(0, height-radii[3]*2, radii[3]*2, radii[3]*2),
};
SkPoint startPoints[4] {
{ corners[0].left(), corners[0].centerY() },
{ corners[1].centerX(), corners[1].top() },
{ corners[2].right(), corners[2].centerY() },
{ corners[3].centerX(), corners[3].bottom() },
};
SkPath path;
for (int i = 0; i < 4; ++i) {
path.arcTo(corners[i], startAngles[i], 90, i == 0);
path.lineTo(startPoints[(i + 1) % 4]);
}
path.close();
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(SK_ColorWHITE);
paint.setStyle(SkPaint::kFill_Style);
canvas->clear(SK_ColorTRANSPARENT);
canvas->drawPath(path, paint);
}