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
21
void draw(SkCanvas* canvas) {
SkBitmap bitmap;
bitmap.allocN32Pixels(64, 64);
bitmap.eraseColor(SK_ColorTRANSPARENT);
std::default_random_engine rng;
const auto randUint = [&rng](uint32_t min, uint32_t max) -> uint32_t {
return std::uniform_int_distribution<uint32_t>(min, max)(rng);
};
for (int y = 0; y < 256; y += 64) {
for (int x = 0; x < 256; x += 64) {
SkColor color = randUint(0, UINT_MAX);
uint32_t w = randUint(4, 32);
uint32_t cx = randUint(0, 64 - w);
uint32_t h = randUint(4, 32);
uint32_t cy = randUint(0, 64 - h);
bitmap.erase(color, SkIRect::MakeXYWH(cx, cy, w, h));
canvas->drawImage(bitmap.asImage(), x, y);
}
}
}