Skip to content

Commit 4f74d8b

Browse files
Create contributionX.json
Adding my showcase submission for a print design
1 parent 3cbf15c commit 4f74d8b

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

contributionX.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
float x = 10; //declares and initialises the value of the variable x
2+
float y = 10; //declares and initialises the value of the variable y
3+
float gap = 20; //declares and initialises the value of the variable gap (boxes' width and height)
4+
5+
6+
void setup() {
7+
size(640, 380);
8+
}
9+
10+
void draw() {
11+
background(0);
12+
13+
for (x = 10; x < width; x = x + gap) { //this outer loop moves the position of x across the canvas
14+
15+
for (y = 10; y < height; y = y + gap) { // this inner loop draws boxes at (x,y) for each row.
16+
17+
stroke(255);
18+
strokeWeight(2);
19+
fill(255, 0, 0);
20+
ellipseMode(CENTER); // the arcs are positioned based on their centre
21+
22+
float r = random(0, 1); // there is 50% probability that r can be less or greater than 0.5
23+
if (r < 0.5) {
24+
arc(x, y, gap, gap, -HALF_PI, -HALF_PI + PI); // draws an arc at position coordinate(x,y), with the width and height of the ellipse, starting at position clockwise at position 12 pmand stopping at 6pm
25+
} else {
26+
stroke(255, 255, 0);
27+
fill(0, 0, 255);
28+
arc(x, y, gap, gap, HALF_PI, HALF_PI + PI); // draws an arc starting a position 6 pm and stopping at 12 pm
29+
}
30+
}
31+
noLoop(); // after first execution processing stops repeating the draw
32+
}
33+
}

0 commit comments

Comments
 (0)