let globalPointSize = 50;
let pointSizeDecrement = 0.5;
img = loadImage("IMG_9124.jpg");
createCanvas(img.width/4, img.height/4);
wis = min(img.width, img.height);
if(globalPointSize <= minPointSize) {
let cellWidth = width / gridSize;
let cellHeight = height / gridSize;
for(let i = 0; i < gridSize; i++) {
for(let j = 0; j < gridSize; j++) {
let pointSize = map(i + j, 0, 2 * gridSize, globalPointSize, 12);
var pds = new PoissonDiskSampling({
shape: [cellWidth, cellHeight],
minDistance: pointSize / 2,
maxDistance: pointSize * 2,
for(let p = 0; p < points.length; p++) {
let x = i * cellWidth + points[p][0];
let y = j * cellHeight + points[p][1];
let imgX = floor(map(x, 0, width, 0, img.width));
let imgY = floor(map(y, 0, height, 0, img.height));
let index = 4 * (imgY * img.width + imgX);
let col = [img.pixels[index], img.pixels[index+1], img.pixels[index+2], img.pixels[index+3]];
ellipse(x, y, pointSize, pointSize);
pointSizeDecrement = log(globalPointSize) / 10;
if(pointSizeDecrement < 0.01) pointSizeDecrement = 0.01;
globalPointSize -= pointSizeDecrement;
saveCanvas('pointil_pds_a-' + floor(random(100)), 'png');