-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcircles.g2d
48 lines (39 loc) · 1018 Bytes
/
circles.g2d
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
pointInCircle := fn(radius) {
r := radius * sqrt(randf())
theta := randf() * 2 * PI
x := r * cos(theta)
y := r * sin(theta)
return [x, y]
}
// Creates an image that is 480 x 120 pixels
size(256)
// Clear the image
clear()
viewport(-105, 105, -105, 105)
// Do iterations
i := 0
while(i < 200) {
// circle radius
r := randf(5, 50)
// circle center
c := pointInCircle(r)
// draws the circle
circle(c[0], c[1], r)
// generate a random integer...
// if it is even
if randi() % 2 == 0 {
// fill the circle with a black color and a random transparency
fillColor(randi(255), randi(255), randi(255), randi(50, 150))
fill()
} else {
//...if it's odd, outline the circle
strokeColor(randi(0, 20), randi(0, 20), randi(0, 20), randi(50, 150))
// Sets the pen size
strokeWeight(randf(1, 6))
stroke()
}
// increment the counter
i = i + 1
}
// save the image
snapshot("circles.png")