xxxxxxxxxx
65
function preload() {
img = loadImage('o.jpg');
}
function setup() {
createCanvas(294, 294);
img_wind = createImage(width, height);
noLoop();
}
function draw() {
blendMode(BLEND);
image(img, 0, 0, width, height);
filter(BLUR, 3);
filter(DILATE);
drawImage();
image(img_wind, 0, 0, width, height);
blendMode(SCREEN);
image(img, 0, 0, width, height);
}
function drawImage() {
img.loadPixels();
img_wind.loadPixels();
var i = width * height,
red, green, blue,
x, y, xy,
r, j;
while( i > 0 ) {
i -= floor(random(30));
x = i % width;
y = floor(i / height);
xy = (x + y * width) * 4;
red = img.pixels[xy];
green = img.pixels[xy + 1];
blue = img.pixels[xy + 2];
if (red == 255 && green == 255 && blue == 255 ) {
img_wind.pixels[xy] = 255;
img_wind.pixels[xy + 1] = 255;
img_wind.pixels[xy + 2] = 255;
img_wind.pixels[xy + 3] = 255;
r = floor(random(5, random(10, 35)));
for (j = 0; j < r; j++) {
xy = (max(0, x - j) + y * width) * 4;
img_wind.pixels[xy] = 123;
img_wind.pixels[xy + 1] = 234;
img_wind.pixels[xy + 2] = 255;
img_wind.pixels[xy + 3] = map(j, 0, r, 255, 0);
}
}
}
img_wind.updatePixels();
}