08-28-2023, 03:24 PM
Psychedelic Star Swirl
Well according to Search here i haven't posted this one yet.
Just got it working in QBJS as well with following code:
Code: (Select All)
'Option _Explicit
'_Title "Psychedelic Star Swirl bplus 2018-03-04" ' attempt QBJS
' translated from
' Psychedelic Star Swirl.bas SmallBASIC 0.12.8 [B+=MGA] 2017-03-03
' 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
Const xmax = 1200
Const ymax = 760
Screen _NewImage(xmax, ymax, 32)
'_ScreenMove 70, 0
Dim Shared r, g, b, clr
'whatever screen size your device here is middle
Dim cx, cy, k$, size, radius, angle, sangle, x, y, r2
cx = xmax / 2: cy = ymax / 2: r = Rnd: g = Rnd: b = Rnd: k$ = " "
While _KeyDown(27) = 0
size = 1
radius = .06
angle = sangle
Cls
While radius < 800
x = Cos(angle) * radius
y = Sin(angle) * radius
r2 = (x ^ 2 + y ^ 2) ^ .5
size = 4 * r2 ^ .25
For r = size To 1 Step -4
'cc = 160 + 95 * radius/400 - r/size*120
chColor
star cx + x, cy + y, r / 3, r * 1.6, 5, Rnd * 360
Next
angle = angle - .4
radius = radius + 1
Wend
_Display ' update screen with new image
_Limit 15 '<<<<<<<<<<<<<<<<<<<<<<<<<< adjust to higher speeds if you dare
sangle = sangle + _Pi(1 / 18)
Wend
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
Dim pAngle, radAngleOffset, x1, y1, i, x2, y2, x3, y3
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
Sub chColor ()
clr = clr + 1
Color _RGB32(127 + 127 * Sin(r * clr), 127 + 127 * Sin(g * clr), 127 + 127 * Sin(b * clr))
If clr > 100000 Then r = Rnd * Rnd: g = Rnd * Rnd: b = Rnd * Rnd: clr = 0
End Sub
Function RAD (dA)
RAD = _Pi(dA / 180)
End Function
Psychedelic Star Swirl
b = b + ...