xxxxxxxxxx
const picture = "fuschlsee.jpeg";
let noise;
let img;
let count = 0;
const sizes = [80,60,40,25]
let size;
function preload(){
img = loadImage(picture);
}
function setup() {
if(windowWidth<windowHeight){
createCanvas(windowWidth*0.8,img.height*windowWidth/img.width*0.8);
}else{
createCanvas(img.width*windowHeight/img.height*0.8,windowHeight*0.8);
}
noise = 0.02*height;
size = 100;
}
function draw() {
let j= (count*size)%img.width;
let i = floor(count*size/img.width)*size;
if(i>=img.height){
if(sizes.length==0){
noLoop();
}
size = sizes.shift();
count=0;
return;
}
img.loadPixels();
noStroke();
imageMode(CENTER);
let col = getPixel(j,i);
let brushX = map(j,0,img.width,0,width);
let brushY = map(i,0,img.height,0,height);
let r = random(noise,noise*2);
let touch = createTouch(size,col);
push();
translate(brushX,brushY);
rotate(random(TWO_PI));
image(touch,0,0);
pop();
count++;
}
function getPixel(x, y) {
let i = (y * img.width + x) * 4;
let R = map(img.pixels[i],0,255,50,220);
let G = map(img.pixels[i + 1],0,255,50,210);
let B = map(img.pixels[i + 2],0,255,50,220);
return [R, G, B, 170];
}
function createTouch(size,c){
let img = createGraphics(size*1,size*1);
let w = img.width;
let h = img.height;
img.rectMode(CENTER);
img.noStroke();
img.fill(c);
for(let i=0; i<40; i++){
img.rect(w/40*i,h/2,w/40,random(h));
}
return img;
}