Color spiral

For finished programs
Post Reply
User avatar
kibernetik
Site Admin
Posts: 142
Joined: Tue Aug 06, 2019 3:03 pm

Color spiral

Post by kibernetik » Thu Sep 05, 2019 4:26 pm

Code: Select all

'Archimedean spiral, in polar coordinates
'by "Dutchman" Ton Nillesen
'originally coded for SmartBasic, december 2016
'mod by Mr.K
[
In polar coordinates (r,phi) the spiral can be described 
by the equation r=a+b*phi with real numbers a and b.
Parameter 'a' determines the starting point,
while 'b' controls the distance between successive turns.
]
DRAW CLEAR 1 1 0.5
DRAW SIZE 2
draw manual
for r = 1 to 30 step 0.1
  'draw color 1 (30-r)/30 0
  draw color hsv2rgb|3 360*r/30 1 1
  spiral r
  draw update
next

'--- Parameters
def spiral b
a=0  ' start value on real axis
dphi=0.05 ' angular increment
' --- constants
sw,sh=SCRSIZE|2
x0=sw/2 : y0=sh/2
' --- initiate graphics
DRAW AT x0+a,y0
' --- loop
phi=0 ' angular starting value
DO
  r=a+b*phi
  z=r*EXP(1i*phi)
  x,y = x0+REAL(z),y0-IMAG(z)
  DRAW TO x,y
  phi+=dphi
REDO IF x>0 and x<sw and y>0 and y<sh
enddef
Снимок экрана 2019-09-05 в 21.25.32.jpg
Снимок экрана 2019-09-05 в 21.25.32.jpg (244.41 KiB) Viewed 790 times

User avatar
Dutchman
Posts: 151
Joined: Tue Aug 06, 2019 4:47 pm
Location: Netherlands

Re: Color spiral

Post by Dutchman » Thu Sep 05, 2019 4:41 pm

Colorful addition, but it hides the essence of equidistant turns ;)
Archimedian spiral.JPG
Archimedian spiral.JPG (33.83 KiB) Viewed 786 times

Code: Select all

'Archimedean spiral, in polar coordinates
'by "Dutchman" Ton Nillesen
'originally coded for SmartBasic, december 2016
[
In polar coordinates (r,phi) the spiral can be described 
by the equation r=a+b*phi with real numbers a and b.
Parameter 'a' determines the starting point,
while 'b' controls the distance between successive turns.
]
'--- Parameters
a=0  ' start value on real axis
b=10 ' amplitude parameter
dphi=0.1 ' angular increment
' --- constants
sw,sh=SCRSIZE|2
x0=sw/2 : y0=sh/2
edge=MIN(x0,y0) ' circular limit
' --- initiate graphics
DRAW CLEAR 1,1,0.5
DRAW COLOR 1,0,0
DRAW SIZE 3
DRAW AT x0+a,y0
' --- loop
phi=0 ' angular starting value
DO
  r=a+b*phi
  z=r*EXP(1i*phi)
  DRAW TO x0+REAL(z),y0-IMAG(z)
  phi+=dphi
REDO IF ABS(z)<=edge
END
It is still a long way to go

User avatar
kibernetik
Site Admin
Posts: 142
Joined: Tue Aug 06, 2019 3:03 pm

Re: Color spiral

Post by kibernetik » Thu Sep 05, 2019 4:56 pm

Please note the spiral end condition I implemented - it ends perfectly at the edge of the screen.

User avatar
Dutchman
Posts: 151
Joined: Tue Aug 06, 2019 4:47 pm
Location: Netherlands

Re: Color spiral

Post by Dutchman » Thu Sep 05, 2019 5:14 pm

👍 :D
It is still a long way to go

Post Reply