|
1 | 1 | # CIRCLE |
2 | 2 |
|
3 | | -> CIRCLE [STEP] x,y,r [,aspect [, color]] [COLOR color] [FILLED] |
| 3 | +> CIRCLE [STEP] x, y, r [, aspect [, color]] [COLOR color] [FILLED] |
4 | 4 |
|
5 | | -Draws a circle (or an ellipse if the aspect is specified). |
| 5 | +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. |
6 | 6 |
|
7 | | -Example 1: Draw a filled white circle |
| 7 | +By default CIRCLE draws with anti-aliasing. For details, see: [Fast, Antialiased Circles and Ellipses](https://yellowsplash.wordpress.com/2009/10/23/fast-antialiased-circles-and-ellipses-from-xiaolin-wus-concepts/) To turn off anti-aliasing use `option predef antialias off` |
| 8 | + |
| 9 | +### Example 1: Draw a filled white circle |
8 | 10 |
|
9 | 11 | ``` |
10 | 12 | circle 200, 200, 150 COLOR 15 FILLED |
11 | 13 | ``` |
12 | 14 |
|
13 | | -Example 2: Draw a ellipse with aspect ration 1:2 |
| 15 | +### Example 2: Draw a ellipse with aspect ration 1:2 |
14 | 16 |
|
15 | 17 | ``` |
16 | 18 | circle 200, 200, 150, 0.5 |
17 | 19 | ``` |
18 | 20 |
|
19 | | -Example 3: Draw a flower |
20 | | - |
21 | | -~~~ |
| 21 | +### Example 3: Draw a flower |
22 | 22 |
|
| 23 | +``` |
23 | 24 | ' Aspect ratio is relation between width-height of a circle, |
24 | 25 | ' for example: |
25 | 26 | ' aspect = 1 = Perfect circle; |
@@ -63,33 +64,36 @@ Circle CENTER, RADIUS, ASPECT_RATIO Color 14 |
63 | 64 | ' print text in the middle of main circle: |
64 | 65 | At CENTER(0) - (Txtw(TEXT) \ 2), CENTER(1) - (Txth(TEXT) \ 2) |
65 | 66 | Color 15: Print TEXT; |
66 | | -~~~ |
| 67 | +``` |
67 | 68 |
|
68 | | -Example 4: Smiley Face |
| 69 | +### Example 4: Smiley Face |
69 | 70 |
|
70 | | -~~~ |
| 71 | +``` |
71 | 72 | ' SmallBASIC 0.12.2 [B+=MGA] 2016-03-16 |
72 | 73 | ' Smiley Face |
73 | | -cx=xmax/2:cy=ymax/2:rface=250:reye=50:xle=cx-100:xre=cx+100:dir=1 |
| 74 | +cx = xmax/2 |
| 75 | +cy = ymax/2 |
| 76 | +rface = 250 |
| 77 | +reye = 50 |
| 78 | +xle = cx - 100 |
| 79 | +xre = cx + 100 |
| 80 | +dir = 1 |
74 | 81 | while 1 |
75 | 82 | cls |
76 | | - circle cx,cy,rface,1,14 filled |
77 | | - circle xle,cy,reye,1-a,9 filled |
78 | | - circle xre,cy,reye,1-a,9 filled |
79 | | - circle cx,cy+130-a*50,100+a*50,.21+2*a,12 filled |
80 | | - circle cx,cy+100-a*50,100+a*50,.21+a,14 filled |
81 | | - at 0,0 :?a |
| 83 | + circle cx, cy, rface, 1, 14 filled |
| 84 | + circle xle, cy, reye, 1 - a, 9 filled |
| 85 | + circle xre, cy, reye, 1 - a, 9 filled |
| 86 | + circle cx, cy + 130 - a * 50, 100 + a * 50, .21 + 2 * a, 12 filled |
| 87 | + circle cx, cy + 100 - a * 50, 100 + a * 50, .21 + a, 14 filled |
82 | 88 | showpage |
83 | 89 | delay 1 |
84 | | - a+=.002*dir |
85 | | - if a=.26 then dir=dir*-1 |
86 | | - if a=-.1 then dir=dir*-1 |
| 90 | + a+= .002 * dir |
| 91 | + if a = .26 then dir = dir * -1 |
| 92 | + if a = -.1 then dir = dir *-1 |
87 | 93 | wend |
88 | | -~~~ |
89 | | - |
90 | | -By default CIRCLE draws with anti-aliasing. For details, see: [Fast, Antialiased Circles and Ellipses](https://yellowsplash.wordpress.com/2009/10/23/fast-antialiased-circles-and-ellipses-from-xiaolin-wus-concepts/) |
| 94 | +``` |
91 | 95 |
|
92 | | -To turn off anti-aliasing, add this to the start of your program: |
| 96 | +### Example 5: Turn off anti-aliasing |
93 | 97 |
|
94 | 98 | ``` |
95 | 99 | option predef antialias off |
|
0 commit comments