Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
consolite-compiler/examples/circles.c
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
40 lines (38 sloc)
764 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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); | |
} | |
} |