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
23
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;
}
srand(0);
for (int i = 0; i < (N * N); ++i) {
std::swap(shuffle[i], shuffle[rand() % (N * N - i) + i]);
}
int w = (source.width() - 1) / N + 1;
int h = (source.height() - 1) / N + 1;
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->drawImage(subset.asImage(), w * i, h * j);
}
}
}