xxxxxxxxxx
56
let img;
let ps;
function preload() {
img = loadImage("batman_smile.jpg");
}
// 337 x 270
function setup() {
let C_W = 2592;//337;
let C_H = 1944;//270;
createCanvas(C_W, C_H);
ps = 1;
imageMode(CENTER);
noStroke();
background(255);
img.loadPixels();
/*
let _dx = 0;
let _dy = 0;
for (let _y = 0; _y < height; _y++) {
for (let _x = 0; _x < width; _x++) {
let _pixel = img.get(_x, _y);
fill(_pixel);
if (random() > 0.7)
ellipse(_dx, _dy, 4, 2);
else if (random() > 0.4)
ellipse(_dx, _dy, 2, 4);
else {
rect(_dx, _dy, _dx + 4, _dy + 2);
}
_dx += 2;
}
_dy += 2;
_dx = 0;
}
*/
}
function draw() {
for (let _i = 0; _i < 150; _i++) {
let _x = (int)(random(width));
let _y = (int)(random(height));
fill(img.get(_x, _y));
ellipse(_x, _y, _r, _r);
}
}