Spiral Pearl Swirl 4 SB.bas

Here is hypnotic quicky:

' Spiral Pearl Swirl 4 SB.bas SmallBASIC 0.12.8 [B+=MGA] 2017-03-01
'from Spiral Pearl Swirl.bas for FreeBASIC [B+=MGA] 2017-02-28
'from SdlBasic 3d version 2017-02-28
' inspired by spiral Bang

'whatever screen size your device here is middle
cx = xmax/2 : cy = ymax/2
While 1 'checking for key press slows down interpeter too much
size = 1
radius = .06
angle = sangle
cls
While radius < 400
x = cos(angle) * radius
y = sin(angle) * radius
r2 = (x ^ 2 + y ^ 2) ^ .5
size = 4 * r2 ^ .25
For r = size to 1 step - 2
cc = 160 + 95 * radius/400 - r/size*120
Color (rgb(cc, cc, cc))
Circle cx + x, cy + y, r filled
Next
angle -= .4
radius += 1
Wend
showpage ' update screen with new image
'no delay needed as SB isn't as fast as an FB .exe
sangle = sangle + pi/18
Wend

Very cool in SB as well... (had to put in a small delay - my old optics had trouble keeping up... lol)

J

Another dizzy spin, this one changes color patterns:


' Psychedelic Swirl.bas SmallBASIC 0.12.8 [B+=MGA] 2017-03-02
' from Psychodelic Swirl for Naalaa [B+=MGA] 2017-03-02
' extreme modification of Rick's Swirl there

cx = xmax / 2 : cy = ymax / 2 : StartAngle = 0
clr = 1 : r = rnd : g = rnd : b = rnd

while 1
cls
Bang
showpage
delay 45 ' <<<<<<<<<<<<<<<<<< hey Johnno! ;-))
StartAngle = StartAngle - pi/18
wend

sub
Bang()
angle = StartAngle
size = .1 : radius = .1 : ds = .1
while radius < 400
x = cos(angle) * radius
y = sin(angle) * radius
chColor
rect int(cx + x), int(cy + y), step size/1.3+2, size/1.3+2 filled
angle = angle + 41.0
radius = radius + 1.0
size = size + ds
ds = ds + 0.0001
wend
end

sub
chColor()
clr = clr + 0.1
color rgb(127+127*sin(r*clr), 127+127*sin(g*clr), 127+127*sin(b*clr))
if clr > 10000 then r = rnd : g = rnd : b = rnd : clr = 0
end

It just gets better and better... ;-))


' Psychedelic Star Swirl.bas SmallBASIC 0.12.8 [B+=MGA] 2017-03-03
' from Psychodelic Swirl for Naalaa [B+=MGA] 2017-03-02
' extreme modification of Rick's Swirl there

cx = xmax / 2 : cy = ymax / 2 : StartAngle = 0
clr = 1 : r = rnd : g = rnd : b = rnd

while 1
cls
Bang
showpage
delay 45
StartAngle = StartAngle - pi/18
wend

sub
Bang()
angle = StartAngle
size = .1 : radius = .1 : ds = .1
while radius < 400
x = cos(angle) * radius
y = sin(angle) * radius
For r = size to 1 step -14
chColor
star cx + x, cy + y, r/2.7, r, 7 ,angle
Next
angle = angle + 41.0
radius = radius + 1.0
size = size + ds
ds = ds + 0.0001
wend
end

sub
chColor()
clr = clr + .8
color rgb(127+127*sin(r*clr), 127+127*sin(g*clr), 127+127*sin(b*clr))
if clr > 10000 then r = rnd : g = rnd : b = rnd : clr = 0
end

sub star( x, y, rInner, rOuter, nPoints, angleOffset)
' x, y are same as for circle,
' rInner is center circle radius
' rOuter is the outer most point of star
' nPoints is the number of points,
' angleOffset = angle offset IN DEGREES, it will be converted to radians in sub
' this is to allow us to spin the polygon of n sides
pAngle = RAD(360 / nPoints) : radAngleOffset = RAD(angleOffset)
x1 = x + rInner * cos(radAngleOffset)
y1 = y + rInner * sin(radAngleOffset)
for i = 0 to nPoints - 1
x2 = x + rOuter * cos(i * pAngle + radAngleOffset + .5 * pAngle)
y2 = y + rOuter * sin(i * pAngle + radAngleOffset + .5 * pAngle)
x3 = x + rInner * cos((i + 1) * pAngle + radAngleOffset)
y3 = y + rInner * sin((i + 1) * pAngle + radAngleOffset)
line x1, y1, x2, y2
line x2, y2, x3, y3
x1 = x3 : y1 = y3
next
end sub