xxxxxxxxxx
let img1;
let img2;
let img3;
let figure;
let randomIndex;
function preload() {
img1 = loadImage('https://deckard.openprocessing.org/user426045/visual2178790/h896cad5408e406baab98feac4c1d21e1/roses1.jpeg');
img2 = loadImage('https://deckard.openprocessing.org/user426045/visual2178790/h896cad5408e406baab98feac4c1d21e1/roses2.jpeg');
img3 = loadImage('https://deckard.openprocessing.org/user426045/visual2178790/h896cad5408e406baab98feac4c1d21e1/roses3.jpeg');
figure = loadImage('https://deckard.openprocessing.org/user426045/visual2178790/h896cad5408e406baab98feac4c1d21e1/WuDarren.JPG');
}
function setup() {
createCanvas(1200, 800);
background(0);
rectMode(CENTER);
randomIndex = int(random(3));
}
function draw() {
let chosenImg;
if (randomIndex === 0) {
chosenImg = img1;
} else if (randomIndex === 1) {
chosenImg = img2;
} else {
chosenImg = img3;
}
chosenImg.resize(width, height);
for (let i = 0; i < 100; i++) {
let x = int(random(width));
let y = int(random(height));
let col = chosenImg.get(x, y);
frameRate(300);
noStroke();
let rotation = map(saturation(col), 0, 255, 0, 360);
let length = map(brightness(col), 0, 255, 0, 100);
fill(red(col), green(col) + random(-100, 0), blue(col) + random(-100, 0), 100);
push();
rectMode(CENTER);
translate(x + mouseX / 10, y + mouseY / 10);
rotate(radians(rotation));
rect(0, 0, 2, length);
pop();
}
push();
blendMode(DARKEST);
image(figure, windowWidth - 200, windowHeight - 150, 200, 150);
pop();
}