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
39
void draw(SkCanvas *canvas) {
canvas->clear(SK_ColorBLACK);
const int centerX = 400;
const int centerY = 400;
SkPath rocket;
SkParsePath::FromSVGString("M2.35,24.5A144.77,144.77,0,0,0,26.85,5.4c24.2-24.2,26.9-45.5,24.4-53.1l10.8-10.8a2.54,2.54,0,0,0,0-3.6,2.53,2.53,0,0,0-3.6,0L47.65-51.3c-7.6-2.5-28.9.2-53.1,24.4A144.77,144.77,0,0,0-24.55-2.4c-8.1-2-22.2-2-32,8.9-11.2,12.3-4.6,24-2.1,21.6,2-2.1,5.4-14.4,20.2-4.9-2.4,5-2.3,8.1-.7,9.6l6.3,6.3c1.6,1.6,4.6,1.8,9.7-.7,9.4,14.8-2.9,18.2-4.9,20.3-2.5,2.4,9.2,9,21.5-2.2,10.9-9.8,10.9-23.9,8.9-32Zm15.3-42.2a9.42,9.42,0,0,1,0-13.2,9.24,9.24,0,0,1,13.2,0,9.24,9.24,0,0,1,0,13.2,9.42,9.42,0,0,1-13.2,0m-60.1,53.6s-10,1.8-13.7,20.2c18.4-3.6,20.2-13.7,20.2-13.7C-38.05,40.2-40.25,38.1-42.45,35.9Z", &rocket);
SkPaint fillPaint, strokePaint;
fillPaint.setAntiAlias(true);
strokePaint.setAntiAlias(true);
strokePaint.setStrokeWidth(2);
strokePaint.setStyle(SkPaint::kStroke_Style);
SkColor colors[][2] = {
{0x8888ff00, 0xff88ff00},
{0x880088bb, 0xff0088bb}
};
SkScalar rotation = 0;
for (auto color: colors) {
fillPaint.setColor(color[0]);
strokePaint.setColor(color[1]);
canvas->save();
canvas->translate(centerX, centerY);
canvas->rotate(rotation);
canvas->scale(3, 3);
canvas->drawPath(rocket, fillPaint);
canvas->drawPath(rocket, strokePaint);
canvas->restore();
rotation -= 90;
}
}