-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcircles.js
66 lines (52 loc) · 1.18 KB
/
circles.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
let scrSize;
let imgSize = 2000;
let numCicles = 200;
let cg;
let img;
function setup() {
if (windowWidth > windowHeight) {
scrSize = windowHeight;
} else {
scrSize = windowWidth;
}
createCanvas(scrSize, scrSize);
cg = createGraphics(imgSize, imgSize);
img = createImage(imgSize, imgSize);
background(0);
pixelDensity(1);
cg.background(0);
cg.pixelDensity(1);
}
function draw() {
if (frameCount == 1) {
cg.background(0);
cg.noStroke();
for (let i = 0; i < numCicles; i++) {
let x = imgSize*fxrand();
let y = imgSize*fxrand();
let radius = imgSize*fxrand()/4;
let r = 256*fxrand();
let g = 256*fxrand();
let b = 256*fxrand();
cg.fill(r, g, b, 160);
cg.circle(x, y, radius);
}
img.copy(cg, 0, 0, imgSize, imgSize, 0, 0, imgSize, imgSize);
image(img, 0, 0, scrSize, scrSize);
}
noLoop();
}
function keyPressed() {
if (key == 's') {
img.save("circles-" + fxhash + ".png");
}
}
function windowResized() {
if (windowWidth > windowHeight) {
scrSize = windowHeight;
} else {
scrSize = windowWidth;
}
resizeCanvas(scrSize, scrSize);
image(img, 0, 0, scrSize, scrSize);
}