home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG035.ARC
/
GRAFCIRC.C
< prev
next >
Wrap
Text File
|
1979-12-31
|
1KB
|
65 lines
/********************************************************/
/* */
/* Circle-Plotting Routine for MX-80 Graphics */
/* */
/* Don Brittain 3 January 1983 */
/* */
/********************************************************/
#define NO 0
#define YES 1
extern int flag;
extern int pixplot(), unpixplot();
circle(x,y,r) /* plots circle with center (x,y) and */
/* radius = r */
int x,y,r;
{
register i;
int end, sqt;
long li, lr;
lr=r;
if(flag)
{
end=r-r/4;
for(i=r/4-r; i<=end; i++) {
li=i;
sqt=sqrt(lr*lr-li*li);
pixplot(x+i,y+sqt);
pixplot(x+i,y-sqt);
pixplot(x+sqt,y+i);
pixplot(x-sqt,y+i); }
}
else
{
end=r-r/4;
for(i=r/4-r; i<=end; i++) {
li=i;
sqt=sqrt(lr*lr-li*li);
unpixplot(x+i,y+sqt);
unpixplot(x+i,y-sqt);
unpixplot(x+sqt,y+i);
unpixplot(x-sqt,y+i); }
}
}
sqrt(x) /* Cluge returning approximate square-root of integers */
long x;
{
register i;
if(x<0) {
printf("Argument error in SQRT.\n\n");
return(-1); }
for(i=0; i<x; i++)
if((i*i)>=(x-i/2)) return(i);
}