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
24
void draw(SkCanvas* canvas) {
canvas->drawColor(SK_ColorWHITE);
const int N = 8;
int shuffle[N * N];
for (int i = 0; i < (N * N); ++i) { shuffle[i] = i; }
for (int i = 0; i < (N * N); ++i) {
SkTSwap(shuffle[i], shuffle[rand() % (N * N - i) + i]);
}
int w = (source.width() - 1) / 8 + 1;
int h = (source.height() - 1) / 8 + 1;
srand(0);
for (int i = 0; i < N; ++i) {
for (int j = 0; j < N; ++j) {
int x = shuffle[(N * i) + j] % N;
int y = shuffle[(N * i) + j] / N;
SkBitmap subset;
source.extractSubset(
&subset, SkIRect::MakeXYWH(w*x, h*y, w, h));
canvas->drawBitmap(subset, w*i, h*j);
}
}
}