Post by johnno56 on Sept 18, 2021 6:07:48 GMT -6
Here is a snippet that I converted from QB64.
Not mine. Created by Bplus.
Watch if a little while and notice the changes in the colour.
J
Not mine. Created by Bplus.
xmax = 1200
ymax = 600
title$ = "Plasma Text Demo by Bplus"
'
' "Borrowed" from QB64 (bplus)
'
center_x = windowpos_centered
center_y = windowpos_centered
WindowOpen(1,title$,center_x,center_y,xmax,ymax,WindowMode(1,0,0,0,0),1)
SetWindowAutoClose(1, 0)
CanvasOpen(1,xmax,ymax,0,0,xmax,ymax,0)
randomize(timer)
' Display message on a blank screen
'
mess$ = "PLASMA TEXT DEMO "
setColor(rgb(255, 255, 255))
prints(mess$)
w = 8 * length(mess$)
h = 8
Dim p[w, h]
Dim pR
Dim pG
Dim pB
Dim lc
Dim cN
black = rgb(0, 0, 0)
' SCAN the the text pixels and store in an array
'
for y = 0 to h
for x = 0 to w
if getPixel(x, y) <> black then
p[x, y] = 1
end if
next
next
cls
'======================================================================
'function range(minimum, maximum)
' return minimum + rand(maximum - minimum)
'end function
Sub resetPlasma()
pR = (rand(1000) / 1000) ^ 2
pG = (rand(1000) / 1000) ^ 2
pB = (rand(1000) / 1000) ^ 2
End Sub
Sub changePlasma()
cN = cN + 1
setColor(rgb(127 + 127 * sin(pR * 0.3 * cN), 127 + 127 * sin(pG * 0.3 * cN), 127 + 127 * sin(pB * 0.3 * cN)))
End Sub
'======================================================================
clearcanvas
' Message co-ordinates
xo = 200
yo = 235
' Image multiplier
m = 6
resetPlasma()
do
for y = 0 to h - 1
for x = 0 to w - 1
if p[x, y] then
changePlasma()
else
setColor(rgb(0, 0, 0))
end if
boxFill(xo + x * m, yo + y * m, xo + x * m + m, yo + y * m + m)
next
next
update()
wait(100)
lc = lc + 1
if lc mod (20 + rand(20)) = 0 then
resetPlasma()
end if
if Not WindowExists(1) Or WindowEvent_Close(1) Then
end
end if
update()
loop until key(27) = 1
Watch if a little while and notice the changes in the colour.
J