CIRCLE Statement
----------------------------------------------------------------------------
Action
Draws an ellipse or circle with a specified center and radius.
Syntax
CIRCLE -STEP- (x!,y!), radius!-, -color&- -, -start!- -, -end!- -, aspect!--
Remarks
The following list describes the parts of the CIRCLE statement.
-----------------------------------------------------------------------------
Part Description
----------------------------------------------------------------------------
STEP The STEP option specifies that
x! and y! are offsets relative to
current graphics cursor position,
enabling use of relative
coordinates.
x!, y! The screen coordinates for the
center of the circle or ellipse.
radius! The radius of the circle or
ellipse in the units of the
Part Description
----------------------------------------------------------------------------
ellipse in the units of the
current coordinate system, which
is determined by the most recently
executed SCREEN statement, along
with any VIEW or WINDOW
statements.
color& The attribute of the desired color.
See the entries for the COLOR and
SCREEN statements for more
information. The default color is
the foreground color.
start!, end! The start! and end! angles, in
radians, for the arc to draw. The
start! and end! arguments are
used to draw partial circles or
ellipses. The arguments may range
in value from -2- radians to 2-
Part Description
----------------------------------------------------------------------------
in value from -2- radians to 2-
radians, where - - 3.141593. The
default value for start! is 0
radians. The default value for
end! is 2- radians.
To convert values from degrees to
radians, multiply the angle (in
degrees) by --180 (which equals
.0174532925199433).
If start! is negative, CIRCLE
draws a radius to start! and
treats the angle as positive. If
end! is negative, CIRCLE draws a
radius to end! and treats the
angle as positive. If both start!
and end! are negative, CIRCLE
draws a radius to both start! and
Part Description
----------------------------------------------------------------------------
draws a radius to both start! and
end! and treats the angle as
positive.
The start! angle can be less than
the end! angle. If you specify
end! but not start!, the arc is
drawn from zero to end!; if you
specify start! but not end!, the
statement draws an arc from
start! to 2-.
aspect! The aspect ratio, or the ratio of
the y! radius to the x! radius.
The default value for aspect! is
the value required to draw a round
circle in the screen mode. This
value is calculated as follows.
Part Description
----------------------------------------------------------------------------
aspect! = 4 * ( ypixels-xpixels
)-3
In this formula, xpixels by
ypixels is the screen resolution.
For example, in screen mode 1,
where the resolution is 320 x 200,
the default for aspect! is 4 *
(200-320)-3, or 5-6.
If the aspect ratio is less than
one, radius! is the x! radius.
If aspect is greater than one,
radius! is equal to the y! radius.
To draw a radius to angle 0 (a horizontal line segment to the right), do not
give the angle as -0. Instead, use a very small non-zero value as
shown in the following code fragment, which draws a one-quarter wedge of a
circle.
SCREEN 2
CIRCLE (200,100),60,,-.0001,-1.57
You can omit an argument in the middle of the statement, but you must
include the argument's comma. In the following statement, color& has been
omitted.
CIRCLE STEP (150,200),94,,0.0,6.28
If you omit a trailing argument, do not include its corresponding comma in
the statement.
The CIRCLE statement updates the graphics cursor position to the center of
the ellipse or circle after drawing is complete.
You can use coordinates that are outside the screen or viewport. You can
show coordinates as absolutes, or you can use the STEP option to show the
position of the center point in relation to the previous point of reference.
For example, if the previous point of reference were (10,10), the statement
below would draw a circle with radius 75 and center offset 10 from the
current x coordinate and 5 from the current y coordinate. The circle's
center would be (20,15).
CIRCLE STEP (10,5), 75
Example
The following example first draws a circle with the upper-left quarter
missing. It then uses relative coordinates to position a second circle
within the missing quarter circle. Finally, it uses a different aspect ratio
to draw a small ellipse inside the small circle.
CONST PI=3.141593
SCREEN 2
' Draw a circle with the upper-left quarter missing.
' Use negative numbers so radii are drawn.
CIRCLE (320,100), 200,, -PI, -PI-2
' Use relative coordinates to draw a circle within the missing
' quarter.
CIRCLE STEP (-100,-42),100
' Draw a small ellipse inside the circle.
CIRCLE STEP(0,0), 100,,,, 5-25
' Display the drawing until a key is pressed.
LOCATE 25,1 . PRINT "Press any key to end.";
DO
LOOP WHILE INKEY$=""