Plasma updated:
' Text Rotation fun 2.bas SmallBASIC 0.12.13 (B+=MGA) 2019-11-04
'text rotation fun.bas for SmallBASIC 0.12.11 (B+=MGA) 2017-02-02
' more spectacular plasma color please
'global variables
message = "SmallBASIC is fun!"
secWide = txtw(message) + 2
secHigh = txth(message) + 2
dim sect(secWide, secHigh) 'array to store message points
color rgb(200, 200, 200),0 : cls
rect 0, 0, secWide, secHigh, 9
? message
loadSect 0, 0 'load array
'debug checks
'for y = 0 to secHigh
' for x = 0 to secWide
' if sect(x, y) then pset x + 200, y + 200
' next
'next
'input "OK ";ok
dim plasma(5, 3)
cls
gosub resetPlasma
cx = xmax/2 : cy = ymax/2
while 1
cls
dpi = 0
yaxis cx, cy/4, a, 4
dpi = 1
xaxis cx, 3*cy/4, a, 7
dpi = 2
rotate cx/2, cy, a, 3
dpi = 3
rotate 3*cx/2, cy, a -90, 4.5
dpi = 4
rotate cx, cy/2, -4*a + 90, 4
dpi = 5
rotate cx, 3*cy/2, 2*a + 180, 6.5
showpage
delay 10
a = a + 1
if a = 360 then a = 0
wend
pause
end
label resetPlasma
for i = 0 to 5
plasma(i, 0) = rnd ^ 2
plasma(i, 1) = rnd ^ 2
plasma(i, 2) = rnd ^ 2
plasma(i, 3) = 1
next
return
sub dp(i)
plasma(i, 3) = plasma(i, 3) + .1
color rgb(128 + 127*sin(plasma(i,0)*plasma(i,3)), 128 + 127*sin(plasma(i, 1)*plasma(i, 3)), 128 + 127*sin(plasma(i, 2)*plasma(i, 3)))
end
sub loadSect(xstart, ystart)
local x, y, p, black
'these are all global
black = rgb(100 ,100, 100)
for y = 0 to secHigh
for x = 0 to secWide
p = POINT(xstart + x, ystart + y)
if p < black then sect(x, y) = 1 '<== data from screen points
next
next
end
sub rotate(cx, cy, angle, scale) 'and scale
local cax, cay, ra, cc, d, anew, ax,ay
cax = secWide/2 : cay = secHigh/2 'array center
for y = 0 to secHigh
for x = 0 to secWide
cc = sect(x,y)
if (x-cax) <> 0 and cc <> 0 then
d = ((x-cax)^2+(y-cay)^2)^.5
anew = atan((y-cay)/(x-cax))
if x-cax < 0 and y-cay < 0 then anew = anew + pi+rad(angle) '-x,-y
if x-cax < 0 and y-cay >= 0 then anew = anew + pi+rad(angle) '-x,+y
if x-cax >= 0 and y-cay < 0 then anew = anew + rad(angle) '+x,-y
if x-cax >= 0 and y-cay >= 0 then anew = anew + rad(angle) '+x,+y
ax = d*cos(anew):ay=d*sin(anew)
dp dpi
rect int(cx+ax*scale),int(cy+ay*scale) step scale+1, scale+1 filled
end if
next
next
end
sub yaxis(cx, cy, angle, scale)
local cax, cay, cc, ax,ay
cax = secWide/2 : cay = secHigh/2 'array center
for y = 0 to secHigh
for x = 0 to secWide
cc = sect(x,y)
if cc <> 0 then
ax = (x - cax)*cos(rad(angle)):ay= (y - cay)
dp dpi
rect int(cx+ax*scale),int(cy+ay*scale) step scale+1, scale+1 filled
end if
next
next
end
sub xaxis(cx, cy, angle, scale)
local cax, cay, cc, ax,ay
cax = secWide/2 : cay = secHigh/2 'array center
for y = 0 to secHigh
for x = 0 to secWide
cc = sect(x,y)
if cc <> 0 then
ax = (x - cax) :ay = (y - cay) * sin( rad(angle))
dp dpi
rect int(cx+ax*scale),int(cy+ay*scale) step scale+1, scale+1 filled
end if
next
next
end