-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcircles.c
More file actions
40 lines (38 loc) · 764 Bytes
/
circles.c
File metadata and controls
40 lines (38 loc) · 764 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
33
34
35
36
37
38
39
40
/**
* Test circle drawing program in Consolite C.
* Draws circles of random size, color, and position as fast as the
* processor will allow. Takes no input.
*
* @author Robert Fotino, 2016
*/
void draw_circle(uint16 cx, uint16 cy, uint16 r) {
uint16 rSq = r*r;
uint16 x;
uint16 y;
uint16 a;
uint16 b;
uint16 c;
uint16 d;
uint16 ySq;
for (y = 0; y < r; y = y + 1) {
c = cy + y;
d = cy - y;
ySq = y*y;
for (x = 0; x < r; x = x + 1) {
a = cx + x;
b = cx - x;
if (((x*x)+ySq) <= rSq) {
PIXEL(a, c);
PIXEL(a, d);
PIXEL(b, c);
PIXEL(b, d);
}
}
}
}
void main() {
while (1) {
COLOR(RND());
draw_circle(RND() & 0xff, RND() & 0xff, (RND() & 0x1f) + 16);
}
}