Processingソースコード(.pde)
float CELL_SIZE = 50;
int Y_OFFSET = 0;
float x;
float y;
PImage img;
void setup() {
size(500, 500);
background(255);
img = loadImage("<IMAGE_FILE_PATH>");
image(img, 0, -Y_OFFSET, img.width, img.height);
}
void draw() {
int dstx = (int)x;
int dsty = (int)y;
int srcx = (int)x + (int)random(-CELL_SIZE, CELL_SIZE);
int srcy = (int)y + (int)random(-CELL_SIZE, CELL_SIZE);
copy(
img,
srcx, srcy + Y_OFFSET,
(int)CELL_SIZE, (int)CELL_SIZE,
dstx, dsty,
(int)CELL_SIZE, (int)CELL_SIZE
);
x = x + CELL_SIZE;
if (x >= width) {
x = 0;
y = y + CELL_SIZE;
}
}