xxxxxxxxxx
let img;
function preload() {
img = loadImage('./Hikonejo-castle-1.jpg');
}
function setup() {
createCanvas(windowWidth, windowHeight);
img.resize(width, height);
background(0);
rectMode(CENTER);
}
function draw() {
for (let i = 0; i < 100; i++) {
let x = int(random(width));
let y = int(random(height));
let col = img.get(x, y);
noStroke();
let rotation = map(saturation(col), 0, 255, 0, 360);
let length = map(brightness(col), 0, 255, 0, 100);
fill(red(col), green(col), blue(col), 50);
push();
translate(x, y);
rotate(radians(rotation));
rect(0, 0, 2, length);
pop();
}
}