1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// require https://cdn.jsdelivr.net/npm/p5@1.4.0/lib/p5.min.js
function setup() {
createCanvas(600, 300);
fill(100);
noStroke();
rectMode(CENTER);
}
function draw() {
background(50);
noStroke();
fill(200);
stippleRect(100, 100, 100, 100, 0.5);
stippleRect(350, 50, 200, 200, 0.5);
}
function stippleRect(left, top, width, height, drawDensity) {
drawCount = ((width * height) / 25) * drawDensity;
for (i = 0; i < drawCount; i++) {
let x = random(left, left + width);
let y = random(top, top + height);
ellipse(x, y, 5, 5);
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
⌥⌘j Open Console | ⌘s/ctrl-s Update Preview |