Wavy plasma thingy

Started by SToS, November 17, 2024, 08:05:07

Previous topic - Next topic

SToS

Just for fun.... ;D  (Tried to convert it a'la GL version in BlitzMax, but not successful as of yet)

SuperStrict

'Original code by....''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''' Code de demonstration OpenGL   ''''''''''''''''''''''''''''''''''''''''''''
'''' PB6.0 - SPH(2022) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Const DDW:Int = 1024
Const DDH:Int = 768
Const DW2:Int = DDW / 2
Const DH2:Int = DDH / 2
Const DW1:Int = DDW / 4
Const DW3:Int = (DDW / 4) * 3

Global rr1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global rr2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global vv1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global vv2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global bb1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global bb2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000

Global or1:Float = rr1
Global or2:Float = rr2
Global ov1:Float = vv1
Global ov2:Float = vv2
Global ob1:Float = bb1
Global ob2:Float = bb2
Global cr1:Float = 0.001 + RndFloat() * 1000 / 10000
Global cr2:Float = 0.001 + RndFloat() * 1000 / 10000
Global cv1:Float = 0.001 + RndFloat() * 1000 / 10000
Global cv2:Float = 0.001 + RndFloat() * 1000 / 10000
Global cb1:Float = 0.001 + RndFloat() * 1000 / 10000
Global cb2:Float = 0.001 + RndFloat() * 1000 / 10000

Global a1:Float = 0.001 + RndFloat() * 1000 / 35000
Global a2:Float = 0.002 + RndFloat() * 1000 / 35000
Global a3:Float = 0.003 + RndFloat() * 1000 / 35000
Global a4:Float = 0.001 + RndFloat() * 1000 / 35000
Global a5:Float = 0.002 + RndFloat() * 1000 / 35000
Global a6:Float = 0.003 + RndFloat() * 1000 / 35000

Global arr1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global arr2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global avv1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global avv2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global abb1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global abb2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global aor1:Float = arr1
Global aor2:Float = arr2
Global aov1:Float = avv1
Global aov2:Float = avv2
Global aob1:Float = abb1
Global aob2:Float = abb2
Global acr1:Float = 0.001 + RndFloat() * 1000 / 10000
Global acr2:Float = 0.001 + RndFloat() * 1000 / 10000
Global acv1:Float = 0.001 + RndFloat() * 1000 / 10000
Global acv2:Float = 0.001 + RndFloat() * 1000 / 10000
Global acb1:Float = 0.001 + RndFloat() * 1000 / 10000
Global acb2:Float = 0.001 + RndFloat() * 1000 / 10000

Global r1:Int
Global r2:Int
Global v1:Int
Global v2:Int
Global b1:Int
Global b2:Int
Global ar1:Int
Global ar2:Int
Global av1:Int
Global av2:Int
Global ab1:Int
Global ab2:Int
        
Global rr:Int
Global vv:Int
Global arr:Int
Global avv:Int

Function Deg:Float(radians:Float)
Return radians * 180.0 / Pi
End Function

'
' Main
'
Graphics DDW, DDH, 0
SetBlend ALPHABLEND

Repeat
Cls
     
For Local i:Int = 0 To DDH - 1
r1 = Int(63 + Cos(Deg(rr1)) * 63)
r2 = Int(63 + Sin(Deg(rr2)) * 63)
v1 = Int(63 + Cos(Deg(vv1)) * 63)
v2 = Int(63 + Cos(Deg(vv2)) * 63)
b1 = Int(63 + Sin(Deg(bb1)) * 63)
b2 = Int(63 + Sin(Deg(bb2)) * 63)

rr = r1 + v1 + b1
vv = r2 + v2 + b2

SetAlpha 1.0
SetColor r1 + r2, v1 + v2, b1 + b2
DrawLine DW2 - rr, i, DW2 + vv, i

rr1 :+ a1
rr2 :+ a2
vv1 :+ a3
vv2 :+ a4
bb1 :+ a5
bb2 :+ a6
Next

For Local i:Int = 0 To DDW - 1
ar1 = Int(63 + Cos(Deg(arr1)) * 63)
ar2 = Int(63 + Sin(Deg(arr2)) * 63)
av1 = Int(63 + Cos(Deg(avv1)) * 63)
av2 = Int(63 + Cos(Deg(avv2)) * 63)
ab1 = Int(63 + Sin(Deg(abb1)) * 63)
ab2 = Int(63 + Sin(Deg(abb2)) * 63)

arr = ar1 + av1 + ab1
avv = ar2 + av2 + ab2

SetAlpha 0.5
SetColor r1 + r2, v1 + v2, b1 + b2
DrawLine i, DH2 - arr, i, DH2 + avv

arr1 :+ a1
arr2 :+ a2
avv1 :+ a3
avv2 :+ a4
abb1 :+ a5
abb2 :+ a6
Next

or1 :+ cr1
rr1  = or1
or2 :+ cr2
rr2  = or2
ov1 :+ cv1
vv1  = ov1
ov2 :+ cv2
vv2  = ob2
ob1 :+ cb1
bb1  = ob1
ob2 :+ cb2
bb2  = ob2

aor1 :+ acr1
arr1 = aor1
aor2 :+ acr2
arr2 = aor2
aov1 :+ acv1
avv1 = aov1
aov2 :+ acv2
avv2 = aob2
aob1 :+ acb1
abb1 = aob1
aob2 :+ acb2
abb2 = aob2

Flip
Until KeyHit(KEY_ESCAPE) Or AppTerminate()
End

Baggey

Quote from: SToS on November 17, 2024, 08:05:07Just for fun.... ;D  (Tried to convert it a'la GL version in BlitzMax, but not successful as of yet)

SuperStrict

'Original code by....''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''' Code de demonstration OpenGL   ''''''''''''''''''''''''''''''''''''''''''''
'''' PB6.0 - SPH(2022) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Const DDW:Int = 1024
Const DDH:Int = 768
Const DW2:Int = DDW / 2
Const DH2:Int = DDH / 2
Const DW1:Int = DDW / 4
Const DW3:Int = (DDW / 4) * 3

Global rr1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global rr2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global vv1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global vv2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global bb1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global bb2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000

Global or1:Float = rr1
Global or2:Float = rr2
Global ov1:Float = vv1
Global ov2:Float = vv2
Global ob1:Float = bb1
Global ob2:Float = bb2
Global cr1:Float = 0.001 + RndFloat() * 1000 / 10000
Global cr2:Float = 0.001 + RndFloat() * 1000 / 10000
Global cv1:Float = 0.001 + RndFloat() * 1000 / 10000
Global cv2:Float = 0.001 + RndFloat() * 1000 / 10000
Global cb1:Float = 0.001 + RndFloat() * 1000 / 10000
Global cb2:Float = 0.001 + RndFloat() * 1000 / 10000

Global a1:Float = 0.001 + RndFloat() * 1000 / 35000
Global a2:Float = 0.002 + RndFloat() * 1000 / 35000
Global a3:Float = 0.003 + RndFloat() * 1000 / 35000
Global a4:Float = 0.001 + RndFloat() * 1000 / 35000
Global a5:Float = 0.002 + RndFloat() * 1000 / 35000
Global a6:Float = 0.003 + RndFloat() * 1000 / 35000

Global arr1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global arr2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global avv1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global avv2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global abb1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global abb2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global aor1:Float = arr1
Global aor2:Float = arr2
Global aov1:Float = avv1
Global aov2:Float = avv2
Global aob1:Float = abb1
Global aob2:Float = abb2
Global acr1:Float = 0.001 + RndFloat() * 1000 / 10000
Global acr2:Float = 0.001 + RndFloat() * 1000 / 10000
Global acv1:Float = 0.001 + RndFloat() * 1000 / 10000
Global acv2:Float = 0.001 + RndFloat() * 1000 / 10000
Global acb1:Float = 0.001 + RndFloat() * 1000 / 10000
Global acb2:Float = 0.001 + RndFloat() * 1000 / 10000

Global r1:Int
Global r2:Int
Global v1:Int
Global v2:Int
Global b1:Int
Global b2:Int
Global ar1:Int
Global ar2:Int
Global av1:Int
Global av2:Int
Global ab1:Int
Global ab2:Int
        
Global rr:Int
Global vv:Int
Global arr:Int
Global avv:Int

Function Deg:Float(radians:Float)
Return radians * 180.0 / Pi
End Function

'
' Main
'
Graphics DDW, DDH, 0
SetBlend ALPHABLEND

Repeat
Cls
     
For Local i:Int = 0 To DDH - 1
r1 = Int(63 + Cos(Deg(rr1)) * 63)
r2 = Int(63 + Sin(Deg(rr2)) * 63)
v1 = Int(63 + Cos(Deg(vv1)) * 63)
v2 = Int(63 + Cos(Deg(vv2)) * 63)
b1 = Int(63 + Sin(Deg(bb1)) * 63)
b2 = Int(63 + Sin(Deg(bb2)) * 63)

rr = r1 + v1 + b1
vv = r2 + v2 + b2

SetAlpha 1.0
SetColor r1 + r2, v1 + v2, b1 + b2
DrawLine DW2 - rr, i, DW2 + vv, i

rr1 :+ a1
rr2 :+ a2
vv1 :+ a3
vv2 :+ a4
bb1 :+ a5
bb2 :+ a6
Next

For Local i:Int = 0 To DDW - 1
ar1 = Int(63 + Cos(Deg(arr1)) * 63)
ar2 = Int(63 + Sin(Deg(arr2)) * 63)
av1 = Int(63 + Cos(Deg(avv1)) * 63)
av2 = Int(63 + Cos(Deg(avv2)) * 63)
ab1 = Int(63 + Sin(Deg(abb1)) * 63)
ab2 = Int(63 + Sin(Deg(abb2)) * 63)

arr = ar1 + av1 + ab1
avv = ar2 + av2 + ab2

SetAlpha 0.5
SetColor r1 + r2, v1 + v2, b1 + b2
DrawLine i, DH2 - arr, i, DH2 + avv

arr1 :+ a1
arr2 :+ a2
avv1 :+ a3
avv2 :+ a4
abb1 :+ a5
abb2 :+ a6
Next

or1 :+ cr1
rr1  = or1
or2 :+ cr2
rr2  = or2
ov1 :+ cv1
vv1  = ov1
ov2 :+ cv2
vv2  = ob2
ob1 :+ cb1
bb1  = ob1
ob2 :+ cb2
bb2  = ob2

aor1 :+ acr1
arr1 = aor1
aor2 :+ acr2
arr2 = aor2
aov1 :+ acv1
avv1 = aov1
aov2 :+ acv2
avv2 = aob2
aob1 :+ acb1
abb1 = aob1
aob2 :+ acb2
abb2 = aob2

Flip
Until KeyHit(KEY_ESCAPE) Or AppTerminate()
End

Works fine here! lots of bubble gum blobs mutating cool demo!

Thanks for the share I love little demos like this. ;D
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on Acer 24" . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!

SToS

...and using OpenGL functions directly.

SuperStrict

Framework SDL.glsdlmax2d

Import BRL.Random

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''' Code de demonstration OpenGL   ''''''''''''''''''''''''''''''''''''''''''''
'''' PB6.0 - SPH(2022) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Const DDW:Int = 1024
Const DDH:Int = 768
Const DW2:Int = DDW / 2
Const DH2:Int = DDH / 2

Global rr1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global rr2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global vv1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global vv2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global bb1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global bb2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000

Global or1:Float = rr1
Global or2:Float = rr2
Global ov1:Float = vv1
Global ov2:Float = vv2
Global ob1:Float = bb1
Global ob2:Float = bb2
Global cr1:Float = 0.001 + RndFloat() * 1000 / 10000
Global cr2:Float = 0.001 + RndFloat() * 1000 / 10000
Global cv1:Float = 0.001 + RndFloat() * 1000 / 10000
Global cv2:Float = 0.001 + RndFloat() * 1000 / 10000
Global cb1:Float = 0.001 + RndFloat() * 1000 / 10000
Global cb2:Float = 0.001 + RndFloat() * 1000 / 10000

Global a1:Float = 0.001 + RndFloat() * 1000 / 35000
Global a2:Float = 0.002 + RndFloat() * 1000 / 35000
Global a3:Float = 0.003 + RndFloat() * 1000 / 35000
Global a4:Float = 0.001 + RndFloat() * 1000 / 35000
Global a5:Float = 0.002 + RndFloat() * 1000 / 35000
Global a6:Float = 0.003 + RndFloat() * 1000 / 35000

Global arr1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global arr2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global avv1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global avv2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global abb1:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global abb2:Float = RndFloat() * 5 + RndFloat() * 1000 / 1000
Global aor1:Float = arr1
Global aor2:Float = arr2
Global aov1:Float = avv1
Global aov2:Float = avv2
Global aob1:Float = abb1
Global aob2:Float = abb2
Global acr1:Float = 0.001 + RndFloat() * 1000 / 10000
Global acr2:Float = 0.001 + RndFloat() * 1000 / 10000
Global acv1:Float = 0.001 + RndFloat() * 1000 / 10000
Global acv2:Float = 0.001 + RndFloat() * 1000 / 10000
Global acb1:Float = 0.001 + RndFloat() * 1000 / 10000
Global acb2:Float = 0.001 + RndFloat() * 1000 / 10000

Global r1:Int
Global r2:Int
Global v1:Int
Global v2:Int
Global b1:Int
Global b2:Int
Global ar1:Int
Global ar2:Int
Global av1:Int
Global av2:Int
Global ab1:Int
Global ab2:Int
        
Global rr:Int
Global vv:Int
Global arr:Int
Global avv:Int

Function Deg:Float(radians:Float)
Return radians * 180.0 / Pi
End Function

Function SetupOpenGL()
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    glOrtho(0.0, DDW, DDH, 0.0, -1000.0, 1000.0)
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    glEnable(GL_BLEND)
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
    glViewport(0, 0, DDW, DDH)
    glClearColor(0.0, 0.0, 0.0, 1.0)
End Function


'
' Main
'
Graphics DDW, DDH, 0

SetupOpenGL()

Repeat
glClear(GL_COLOR_BUFFER_BIT)
     
For Local i:Int = 0 To DDH - 1
r1 = Int(63 + Cos(Deg(rr1)) * 63)
r2 = Int(63 + Sin(Deg(rr2)) * 63)
v1 = Int(63 + Cos(Deg(vv1)) * 63)
v2 = Int(63 + Cos(Deg(vv2)) * 63)
b1 = Int(63 + Sin(Deg(bb1)) * 63)
b2 = Int(63 + Sin(Deg(bb2)) * 63)

rr = r1 + v1 + b1
vv = r2 + v2 + b2

glBegin(GL_LINES)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glColor4f((r1 + r2) / 255.0, (v1 + v2) / 255.0, (b1 + b2) / 255.0, 1.0)
glVertex2f(DW2 - rr, i)
glVertex2f(DW2 + vv, i)
glEnd()

rr1 :+ a1
rr2 :+ a2
vv1 :+ a3
vv2 :+ a4
bb1 :+ a5
bb2 :+ a6
Next

For Local i:Int = 0 To DDW - 1
ar1 = Int(63 + Cos(Deg(arr1)) * 63)
ar2 = Int(63 + Sin(Deg(arr2)) * 63)
av1 = Int(63 + Cos(Deg(avv1)) * 63)
av2 = Int(63 + Cos(Deg(avv2)) * 63)
ab1 = Int(63 + Sin(Deg(abb1)) * 63)
ab2 = Int(63 + Sin(Deg(abb2)) * 63)

arr = ar1 + av1 + ab1
avv = ar2 + av2 + ab2

glBegin(GL_LINES)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glColor4f((ar1 + ar2) / 255.0, (av1 + av2) / 255.0, (ab1 + ab2) / 255.0, 0.5)
glVertex2f(i, DH2 - arr)
glVertex2f(i, DH2 + avv)
glEnd()

arr1 :+ a1
arr2 :+ a2
avv1 :+ a3
avv2 :+ a4
abb1 :+ a5
abb2 :+ a6
Next

or1 :+ cr1
rr1  = or1
or2 :+ cr2
rr2  = or2
ov1 :+ cv1
vv1  = ov1
ov2 :+ cv2
vv2  = ob2
ob1 :+ cb1
bb1  = ob1
ob2 :+ cb2
bb2  = ob2

aor1 :+ acr1
arr1 = aor1
aor2 :+ acr2
arr2 = aor2
aov1 :+ acv1
avv1 = aov1
aov2 :+ acv2
avv2 = aob2
aob1 :+ acb1
abb1 = aob1
aob2 :+ acb2
abb2 = aob2

Flip
Until KeyHit(KEY_ESCAPE) Or AppTerminate()
End

Baggey

@SToS Love your little Demo translates.

Had to change to RandomDefault again. I do hope you continue this theme for FUN ;)
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on Acer 24" . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!