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
26
sk_sp<SkImage> alpha_image() {
auto s = SkSurfaces::Raster(SkImageInfo::MakeA8(64, 64));
s->getCanvas()->clear(SkColorSetARGB(0x80, 0x00, 0x00, 0x00));
return s->makeImageSnapshot();
}
sk_sp<SkShader> linear_gradient() {
SkPoint gpts[2] = {{0, 0}, {64, 64}};
SkColor gc[3] = {SK_ColorRED, SK_ColorGREEN, SK_ColorMAGENTA};
return SkGradientShader::MakeLinear(gpts, gc, nullptr, 3, (SkTileMode)0);
}
sk_sp<SkColorFilter> color_filter() {
SkScalar colorMatrix[20] = {
1, 0, 0, 0, 0,
0, 0, 1, 0, 0,
0, 1, 0, 0, 0,
0, 0, 0, 1, 0};
return SkColorFilters::Matrix(colorMatrix);
}
void draw(SkCanvas* canvas) {
SkPaint p;
p.setShader(linear_gradient());
p.setColorFilter(color_filter());
auto i = alpha_image();
canvas->scale(2, 2);
canvas->drawImage(i.get(), 32, 32, SkSamplingOptions(), &p);
}