Archimedean spiral: Difference between revisions

m
Replace deprecated functions
m (Replace deprecated functions)
 
(16 intermediate revisions by 9 users not shown)
Line 498:
 
imgsave "spiral-Basic-256.png", "PNG"
</syntaxhighlight>
 
==={{header|BBC BASIC}}===
{{works with|BBC BASIC for Windows}}
[[File:Archimedean_spiral_bbc_basic.jpeg|300px|right]]
<syntaxhighlight lang="bbcbasic"> A=320
VDU 23, 22, A+10; A+10; 8, 16, 16, 128
ORIGIN @size.x%, @size.y%
GCOL 7
FOR I=-(A - A MOD 100) TO A - A MOD 100 STEP 100
LINE I, -A, I, A : LINE -A, I, A, I
NEXT
 
MOVE 0, 0
GCOL 1
VDU 23, 23, 3|
FOR I=0 TO 5 * PI STEP .05
R=A / 16 * I
DRAW R * COS(I), R * SIN(I)
NEXT
</syntaxhighlight>
 
Line 561 ⟶ 581:
Sleep
End</syntaxhighlight>
 
==={{header|FutureBasic}}===
<syntaxhighlight lang="futurebasic">
_maxPoints = 190
 
void local fn DoIt
window 1, @"Archimedean Spiral", (0,0,500,500)
WindowSetBackgroundColor( 1, fn ColorBlack )
pen 3, fn ColorRed
float x, y, angle
long i, a = 10, b = 10, x1 = 250, y1 = 250
for i = 0 to _maxPoints - 1
angle = 0.1 * i
x = (a + b * angle) * cos(angle) + 250
y = (a + b * angle) * sin(angle) + 250
line x1,y1 to x,y
x1 = x : y1 = y
next
end fn
 
fn DoIt
 
HandleEvents
</syntaxhighlight>
{{output}}
[[File:ArchimedeanSpiralFB.png]]
 
==={{header|GW-BASIC}}===
Line 1,081 ⟶ 1,074:
=={{header|Craft Basic}}==
<syntaxhighlight lang="basic">bgcolor 0, 0, 0
cls graphics
fgcolor 255, 255, 0
 
Line 1,094 ⟶ 1,087:
wait
 
next t</syntaxhighlight>
 
end</syntaxhighlight>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|Types,ExtCtrls,Graphics}}
 
 
 
<syntaxhighlight lang="Delphi">
Line 1,130 ⟶ 1,123:
 
{{out}}
[[File:DelphiASpiral.png|frame|none]]
<pre>
</pre>
 
=={{header|EasyLang}}==
 
[https://easylang.dev/show/#cod=JcwxCsAgEETRfk8xdQQRol08TSK4IAZUUG8f11TDg88kzqHz0yKMtjTg4QzNf3rkFFBwCQCk1S4euN+KBoWxVTlvTWkKlF9Xxgma4CRNHw== Run it]
 
<syntaxhighlight lang="easylang">
linewidth 0.4
x = 50
y = 50
while r < 50
line r * cos t + x r * sin t + y
r += 0.05
t += 3
.
</syntaxhighlight>
 
=={{header|FOCAL}}==
Line 1,269 ⟶ 1,277:
 
[[File:ArchimedeanSpiralFrink.svg|400 px]]
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
_maxPoints = 190
 
void local fn DoIt
window 1, @"Archimedean Spiral", (0,0,500,500)
WindowSetBackgroundColor( 1, fn ColorBlack )
pen 3, fn ColorRed
float x, y, angle
long i, a = 10, b = 10, x1 = 250, y1 = 250
for i = 0 to _maxPoints - 1
angle = 0.1 * i
x = (a + b * angle) * cos(angle) + 250
y = (a + b * angle) * sin(angle) + 250
line x1,y1 to x,y
x1 = x : y1 = y
next
end fn
 
fn DoIt
 
HandleEvents
</syntaxhighlight>
{{output}}
[[File:ArchimedeanSpiralFB.png]]
 
=={{header|Go}}==
Line 1,815 ⟶ 1,850:
theta = 0:0.1:2*turns*pi;
polarplot(theta, a + b*theta);</syntaxhighlight>
 
=={{header|Maxima}}==
Using draw package
<syntaxhighlight lang="maxima">
archi_spi(a,b):=wxdraw2d(nticks=200,polar(a+b*theta,theta,1,10*%pi))$
archi_spi(1,1);
</syntaxhighlight>
[[File:Archi spi.png|thumb|center]]
 
=={{header|MiniScript}}==
For use with the [http://miniscript.org/MiniMicro Mini Micro].
<syntaxhighlight lang="miniscript">
clear
x0 = gfx.width / 2
y0 = gfx.height / 2
gfx.clear color.white
for t in range(0, 70 * pi, 0.1)
r = 3.2+ 1.5 * t
x = r * cos(t) + gfx.width / 2
y = r * sin(t) + gfx.height / 2
gfx.line x0, y0, x, y, color.black,2
x0 = x; y0 = y
end for
</syntaxhighlight>
 
Alternative version using a Turtle library included with the [http://miniscript.org/MiniMicro Mini Micro].
 
<syntaxhighlight lang="miniscript">
import "turtle"
radToDegrees = function(rad)
return 180 * rad / pi
end function
 
clear
print Turtle.displayNum
display(Turtle.displayNum).clear
t = new Turtle
for i in range(0, 50, 0.04)
t.forward i
t.left radToDegrees(pi/20)
end for
</syntaxhighlight>
 
=={{header|Nim}}==
Line 2,576 ⟶ 2,653:
return
</syntaxhighlight>
 
=={{header|RPL}}==
[[File:Archimedean.png|thumb|right|HP-48G emulator screenshot]]
{{works with|HP|48G}}
« → a b
« -20 20 DUP2 XRNG YRNG
POLAR RAD 'a+b*t' STEQ { t 0 18.9 } INDEP
ERASE DRAW { } PVIEW
{ EQ PPAR } PURGE
» » '<span style="color:blue">ARCHI</span>' STO
 
1 1 <span style="color:blue">ARCHI</span>
 
=={{header|Ruby}}==
Line 2,811 ⟶ 2,900:
theta +:= delta;
end while;
DRAW_FLUSHflushGraphic;
ignore(getc(KEYBOARD));
end func;</syntaxhighlight>
Line 2,915 ⟶ 3,004:
{{trans|Sidef}}
{{libheader|DOME}}
<syntaxhighlight lang="ecmascriptwren">import "graphics" for Canvas, Color
import "dome" for Window
 
Line 2,943 ⟶ 3,032:
static draw(dt) {}
}</syntaxhighlight>
 
{{out}}
[[File:Wren-Archimedean_spiral.png]]
 
=={{header|XPL0}}==
28

edits