Archimedean spiral: Difference between revisions
Content added Content deleted
(add gwbasic) |
(Added solution for Action!) |
||
Line 15: | Line 15: | ||
Draw an Archimedean spiral. |
Draw an Archimedean spiral. |
||
<br><br> |
<br><br> |
||
=={{header|Action!}}== |
|||
Action! does not provide trigonometric functions. Therefore a simple implementation for Sin and Cos function has been provided. |
|||
<lang Action!>INT ARRAY SinTab=[ |
|||
0 4 9 13 18 22 27 31 36 40 44 49 53 58 62 66 71 75 79 83 |
|||
88 92 96 100 104 108 112 116 120 124 128 132 136 139 143 |
|||
147 150 154 158 161 165 168 171 175 178 181 184 187 190 |
|||
193 196 199 202 204 207 210 212 215 217 219 222 224 226 |
|||
228 230 232 234 236 237 239 241 242 243 245 246 247 248 |
|||
249 250 251 252 253 254 254 255 255 255 256 256 256 256] |
|||
INT FUNC Sin(INT a) |
|||
WHILE a<0 DO a==+360 OD |
|||
WHILE a>360 DO a==-360 OD |
|||
IF a<=90 THEN |
|||
RETURN (SinTab(a)) |
|||
ELSEIF a<=180 THEN |
|||
RETURN (SinTab(180-a)) |
|||
ELSEIF a<=270 THEN |
|||
RETURN (-SinTab(a-180)) |
|||
ELSE |
|||
RETURN (-SinTab(360-a)) |
|||
FI |
|||
RETURN (0) |
|||
INT FUNC Cos(INT a) |
|||
RETURN (Sin(a-90)) |
|||
PROC DrawSpiral(INT x0,y0) |
|||
INT angle,radius,x,y |
|||
Plot(x0,y0) |
|||
FOR angle=0 TO 1800 STEP 5 |
|||
DO |
|||
radius=angle/20 |
|||
x=radius*Cos(angle)/256+x0 |
|||
y=radius*Sin(angle)/256+y0 |
|||
DrawTo(x,y) |
|||
OD |
|||
RETURN |
|||
PROC Main() |
|||
BYTE CH=$02FC,COLOR1=$02C5,COLOR2=$02C6 |
|||
Graphics(8+16) |
|||
Color=1 |
|||
COLOR1=$0C |
|||
COLOR2=$02 |
|||
DrawSpiral(160,96) |
|||
DO UNTIL CH#$FF OD |
|||
CH=$FF |
|||
RETURN</lang> |
|||
{{out}} |
|||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Archimedean_spiral.png Screenshot from Atari 8-bit computer] |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |