DEF GDISK X,Y,R,C
'get the point on the screen that is closest to the center of the circle
VAR PX=MIN(MAX(X,0),512-1)
VAR PY=MIN(MAX(Y,0),512-1)
'if the distance from the center of the circle to the closest onscreen point is
'larger than the radius, then the circle is completely offscreen
VAR DX=PX-X
VAR DY=PY-Y
IF DX*DX+DY*DY > R*R THEN RETURN
'traditional filled circle code
GCIRCLE X,Y,R,8
GPAINT PX,PY,C,8
GCIRCLE X,Y,R,C
END