53 lines
1.5 KiB
Plaintext
53 lines
1.5 KiB
Plaintext
/* Plot three circles. */
|
|
|
|
CIRCLE: PROCEDURE OPTIONS (MAIN);
|
|
declare image (-20:20, -20:20) character (1);
|
|
declare j fixed binary;
|
|
|
|
image = '.';
|
|
image(0,*) = '-';
|
|
image(*,0) = '|';
|
|
image(0,0) = '+';
|
|
|
|
CALL DRAW_CIRCLE (0, 0, 11);
|
|
CALL DRAW_CIRCLE (0, 0, 8);
|
|
CALL DRAW_CIRCLE (0, 0, 19);
|
|
|
|
do j = hbound(image,1) to lbound(image,1) by -1;
|
|
put skip edit (image(j,*)) (a(1));
|
|
end;
|
|
|
|
draw_circle: procedure (x0, y0, radius); /* 14 May 2010. */
|
|
declare ( x0, y0, radius ) fixed binary;
|
|
declare ( ddfx, ddfy, x, y, f ) fixed binary;
|
|
declare debug bit (1) aligned static initial ('0'b);
|
|
|
|
f = 1-radius;
|
|
ddfx = 1;
|
|
ddfy = -2*radius;
|
|
x = 0;
|
|
y = radius;
|
|
image(x0, y0+radius) = '*'; /* Octet 0. */
|
|
image(x0+radius, y0) = '*'; /* Octet 1. */
|
|
image(x0, y0-radius) = '*'; /* Octet 2. */
|
|
image(x0-radius, y0) = '*'; /* Octet 3. */
|
|
|
|
do while (x < y);
|
|
if f >= 0 then
|
|
do; y = y - 1; ddfy = ddfy +2; f = f + ddfy; end;
|
|
x = x + 1;
|
|
ddfx = ddfx + 2;
|
|
f = f + ddfx;
|
|
image(x0+x, y0+y) = '0'; /* Draws octant 0. */
|
|
image(x0+y, y0+x) = '1'; /* Draws octant 1. */
|
|
image(x0+y, y0-x) = '2'; /* Draws octant 2. */
|
|
image(x0+x, y0-y) = '3'; /* Draws octant 3. */
|
|
image(x0-x, y0-y) = '4'; /* Draws octant 4. */
|
|
image(x0-y, y0-x) = '5'; /* Draws octant 5. */
|
|
image(x0-y, y0+x) = '6'; /* Draws octant 6. */
|
|
image(x0-x, y0+y) = '7'; /* Draws octant 7. */
|
|
end;
|
|
end draw_circle;
|
|
|
|
END CIRCLE;
|