xxxxxxxxxx
34
let img;
function preload()
{
img = loadImage ('f.jpg');
}
function setup() {
createCanvas(img.width, img.height);
img.filter(GRAY);
//noStroke();
rectMode(CENTER);
}
function draw() {
background(255);
let tileCount = 10;
let tileWidth = width / tileCount;
let tileHeight = height / tileCount;
for (let gridY = 0; gridY < tileCount; gridY++) {
for (let gridX = 0; gridX < tileCount; gridX++) {
let px = int(gridX * tileWidth + tileWidth / 2);
let py = int(gridY * tileHeight + tileHeight / 2);
let c = img.get(px, py);
let diameter = map(brightness(c), 0, 255, 2, 4);
push();
translate(px, py);
rotate(int(random(4)) * HALF_PI);
strokeWeight(diameter);
line(-tileWidth / 2, 0, tileWidth / 2, 0);
pop();
}
}
}