-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctions.cpp
More file actions
32 lines (28 loc) · 771 Bytes
/
Copy pathFunctions.cpp
File metadata and controls
32 lines (28 loc) · 771 Bytes
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
/**
* Functions.
*
* The drawTarget() function makes it easy to draw many distinct targets.
* Each call to drawTarget() specifies the position, size, and number of
* rings for each target.
*/
void setup() {
size(640, 360);
background(51);
noStroke();
noLoop();
}
void draw() {
drawTarget(width * 0.25, height * 0.4, 200, 4);
drawTarget(width * 0.5, height * 0.5, 300, 10);
drawTarget(width * 0.75, height * 0.3, 120, 6);
}
void drawTarget(float xloc, float yloc, int size, int num) {
float grayvalues = 255.0 / num;
float steps = float(size) / num;
for (int i = 0; i < num; i++) {
fill(i * grayvalues);
ellipse(xloc, yloc,
size - i * steps,
size - i * steps);
}
}