CIRCLE
CIRCLE [STEP] x, y, r [, aspect [, color]] [COLOR color] [FILLED]
Draws a circle (or an ellipse if the aspect is specified). The point
[x, y]
defines the center and r
the radius of
the circle in pixel. To set the aspect ration use aspect
.
An aspect ratio of 1
will draw a circle. color
defines the line color of the circle. If FILLED
is used,
the circle will be filled with the color color
. If STEP is
used x, y
are a step in pixel from the actual graphics
cursor position.
By default CIRCLE draws with anti-aliasing. For details, see: Fast,
Antialiased Circles and Ellipses To turn off anti-aliasing use
option predef antialias off
Example 1: Draw a filled white circle
circle 200, 200, 150 COLOR 15 FILLED
Example 2: Draw a ellipse with aspect ration 1:2
circle 200, 200, 150, 0.5
Example 3: Draw a flower
' Aspect ratio is relation between width-height of a circle,
' for example:
' aspect = 1 = Perfect circle;
' aspect = 1.5 = Stretch circle vertically (ellipse);
' aspect = 0.5 = Stretch circle horizontally (ellipse);
' let's draw perfect circles for the flower:
Const ASPECT_RATIO = 1
' define parameters for main circle:
Const CENTER = [150, 150] ' [x, y] define the center point to draw a circle
Const RADIUS = 50 ' radius in pixels (pixel is a single point)
Const TEXT = "Smile!" ' text to print in the middle of main circle
' define parameters for leafs:
Const LEAF_RADIUS = 30 ' using smaller circles for leafs
' center point for straight leafs (distance from main circle's center):
Const LEAF_CENTER_STRAIGHT = RADIUS + LEAF_RADIUS
' rotate center point for transverse leafs (distance as above):
Const LEAF_CENTER_TRANSVERSE = LEAF_CENTER_STRAIGHT * Sin(Rad(45))
' Start the program:
Print " Press any key to draw leaf by leaf...";
Pause
Cls
' draw one invisible point to set the 'current position':
Pset CENTER Color 0
' let's use shorter variable names (easier to read):
a = ASPECT_RATIO
r = LEAF_RADIUS' draw the straight leafs (relative to the 'current position'):
c = LEAF_CENTER_STRAIGHTCircle Step 0, -c, r, a Color 15 FILLED: Pause ' top
Circle Step 0, +c, r, a Color 14 FILLED: Pause ' down
Circle Step -c, 0, r, a Color 13 FILLED: Pause ' left
Circle Step +c, 0, r, a Color 12 FILLED: Pause ' right
' draw the transverse leafs (relative to the 'current position'):
c = LEAF_CENTER_TRANSVERSECircle Step -c, -c, r, a Color 11 FILLED: Pause ' top-left
Circle Step +c, +c, r, a Color 8 FILLED: Pause ' down-right
Circle Step +c, -c, r, a Color 10 FILLED: Pause ' top-right
Circle Step -c, +c, r, a Color 9 FILLED: Pause ' down-left
' draw the main circle:
Circle CENTER, RADIUS, ASPECT_RATIO Color 14
' print text in the middle of main circle:
At CENTER(0) - (Txtw(TEXT) \ 2), CENTER(1) - (Txth(TEXT) \ 2)
Color 15: Print TEXT;
Example 4: Smiley Face
' SmallBASIC 0.12.2 [B+=MGA] 2016-03-16
' Smiley Face
xmax/2
cx = ymax/2
cy = 250
rface = 50
reye = 100
xle = cx - 100
xre = cx + 1
dir = while 1
cls
circle cx, cy, rface, 1, 14 filled
circle xle, cy, reye, 1 - a, 9 filled
circle xre, cy, reye, 1 - a, 9 filled
circle cx, cy + 130 - a * 50, 100 + a * 50, .21 + 2 * a, 12 filled
circle cx, cy + 100 - a * 50, 100 + a * 50, .21 + a, 14 filled
showpage
delay 1
002 * dir
a+= .if a = .26 then dir = dir * -1
if a = -.1 then dir = dir *-1
wend
Example 5: Turn off anti-aliasing
option predef antialias off
Code samples using CIRCLE
002 numeric variables.bas
3d rotating cube with message.bas
3dtictac.bas
3dttt.bas
3dttt.bas
analog clock.bas
anball 1.0.bas
Another center finder.bas
another look at trig functions.bas
aquarium v2.bas
B+B.bas
balls in 3d cube.bas
balls in 3d cube.bas
bb2fork smurf.bas
bezier_pen.bas
blackbox.bas
Blackbox.bas
blushing snowflakes.bas
boing.bas
bolmo.bas
bomb.bas
bonkers.bas
bopit.bas
bowling7.bas
bplus paddleball.bas
bubbles and triangles.bas
Chaos_1xt.bas
checkers.bas
checkers.bas
Graphics
ARC
CHART
CIRCLE
COLOR
DRAW
DRAWPOLY
IMAGE
LINE
PAINT
PEN
PLOT
POINT
PSET
RECT
RGB
RGBF
SHOWPAGE
TEXTHEIGHT
TEXTWIDTH
TXTH
TXTW
VIEW
WINDOW
XMAX
XPOS
YMAX
YPOS
If there is insufficient information on this page and you wish learn more about CIRCLE,
please send an email to smallbasic@gmail.com. You can help to improve information about
CIRCLE by submitting a pull request,
click View Source for details. Note, an offline language reference text file is also available - see the Download section.