You are not logged in or registered. Please login or register to use the full functionality of this board...
SIGN IN Join Our Community For FREE


Sun Spectacular
08-16-2017, 03:30 PM
Post: #1
 (Print Post)
Sun Spectacular
Code Snippet: [Select]
' sun spectacular.bas for SmallBASIC 0.12.9 (B+=MGA) 2017-08-16

' ==================================================================
'             Press spacebar to inject sun with new Plasma
' ==================================================================

def rand(lo, hi) = (rnd * (hi - lo + 1)) \ 1 + lo
def distance(x1, y1, x2, y2) = ( (x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ .5

sub midInk(r1, g1, b1, r2, g2, b2, fr)
 color rgb(r1+(r2-r1)*fr, g1+(g2-g1)*fr, b1+(b2-b1)*fr)
end

sub resetPlasma() 'all globals
   plasmaR = rnd ^ 2 : plasmaG = rnd ^ 2 : plasmaB = rnd ^ 2 : plasmaN = 0
end

sub setPlasma() 'all globals
 plasmaN += .5
 color rgb(127+127*sin(plasmaR*plasmaN),127+127*sin(plasmaG*plasmaN),127+127*sin(plasmaB*plasmaN))
end

definekey 32, resetPlasma
horizon = rand(ymax-200, ymax-100)
sunx = xmax/2
ray = distance(0, 0, sunx, horizon)
resetPlasma
while 1
 for i= 0 to horizon
   midInk 0, 0, 128, 40, 200, 255, i/horizon
   line 0, i, xmax, i
 next
 for i = horizon to ymax
   midInk 40, 200, 100, 100, 64, 30, (i-horizon)/(ymax-horizon)
   line 0, i, xmax, i
 next
 for r = pi to 2*pi step pi/200
   setPlasma
   line sunx, horizon, sunx + ray*cos(r), horizon + ray*sin(r)
 next
 showpage
 delay 20
wend

Inspired by Ashish inspiration.


Attached File(s) Image(s)
           

B += _
Find all posts by this user
Like Post
08-16-2017, 04:06 PM
Post: #2
 (Print Post)
RE: Sun Spectacular
Sun spec 2.bas with solid fill triangles:
Code Snippet: [Select]
' sun spec 2.bas for SmallBASIC 0.12.9 (B+=MGA) 2017-08-16

' ==================================================================
'             Press spacebar to inject sun with new Plasma
' ==================================================================

def rand(lo, hi) = (rnd * (hi - lo + 1)) \ 1 + lo
def distance(x1, y1, x2, y2) = ( (x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ .5

sub midInk(r1, g1, b1, r2, g2, b2, fr)
 color rgb(r1+(r2-r1)*fr, g1+(g2-g1)*fr, b1+(b2-b1)*fr)
end

sub resetPlasma() 'all globals
   plasmaR = rnd ^ 2 : plasmaG = rnd ^ 2 : plasmaB = rnd ^ 2 : plasmaN = 0
end

sub setPlasma() 'all globals
 plasmaN += .5
 color rgb(127+127*sin(plasmaR*plasmaN),127+127*sin(plasmaG*plasmaN),127+127*sin(plasmaB*plasmaN))
end

definekey 32, resetPlasma
horizon = rand(ymax-200, ymax-100)
sunx = xmax/2
ray = distance(0, 0, sunx, horizon)
resetPlasma
while 1
 for i= 0 to horizon
   midInk 0, 0, 128, 40, 200, 255, i/horizon
   line 0, i, xmax, i
 next
 for i = horizon to ymax
   midInk 40, 200, 100, 100, 64, 30, (i-horizon)/(ymax-horizon)
   line 0, i, xmax, i
 next
 for r = pi to 2*pi+pi/400 step pi/400
   if r = pi then
     p1x = sunx + ray*cos(r) : p1y = horizon + ray*sin(r)
   else
     p2x = sunx + ray*cos(r) : p2y = horizon + ray*sin(r)
     dim t()
     t << sunx : t << horizon
     t << p1x  : t << p1y
     t << p2x  : t << p2y
     t << sunx : t << horizon
     setPlasma
     drawpoly t filled
     p1x = p2x : p1y = p2y
   fi
 next
 showpage
 delay 20
wend


Attached File(s) Image(s)
           

B += _
Find all posts by this user
Like Post
08-16-2017, 04:29 PM
Post: #3
 (Print Post)
RE: Sun Spectacular
1 + 2 = 3
Code Snippet: [Select]
' sun spec 3.bas for SmallBASIC 0.12.9 (B+=MGA) 2017-08-16

' ==================================================================
'             Press spacebar to inject sun with new Plasma
' ==================================================================

def rand(lo, hi) = (rnd * (hi - lo + 1)) \ 1 + lo
def distance(x1, y1, x2, y2) = ( (x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ .5

sub midInk(r1, g1, b1, r2, g2, b2, fr)
 color rgb(r1+(r2-r1)*fr, g1+(g2-g1)*fr, b1+(b2-b1)*fr)
end

sub resetPlasma() 'all globals
   plasmaR = rnd ^ 2 : plasmaG = rnd ^ 2 : plasmaB = rnd ^ 2 : plasmaN = 0
end

sub setPlasma() 'all globals
 plasmaN += .5
 color rgb(127+127*sin(plasmaR*plasmaN),127+127*sin(plasmaG*plasmaN),127+127*sin(plasmaB*plasmaN))
end

definekey 32, resetPlasma
horizon = rand(ymax-200, ymax-100)
sunx = xmax/2
ray = distance(0, 0, sunx, horizon)
resetPlasma
while 1
 for i= 0 to horizon
   midInk 0, 0, 128, 40, 200, 255, i/horizon
   line 0, i, xmax, i
 next
 for i = horizon to ymax
   midInk 40, 200, 100, 100, 64, 30, (i-horizon)/(ymax-horizon)
   line 0, i, xmax, i
 next
 for r = pi to 2*pi+pi/200 step pi/200
   if r = pi then
     p1x = sunx + .1*ray*cos(r) : p1y = horizon + .1*ray*sin(r)
   else
     p2x = sunx + .1*ray*cos(r) : p2y = horizon + .1*ray*sin(r)
     dim t()
     t << sunx : t << horizon
     t << p1x  : t << p1y
     t << p2x  : t << p2y
     t << sunx : t << horizon
     setPlasma
     drawpoly t filled
     p1x = p2x : p1y = p2y
   fi
   if r <= 2 * pi then
     line sunx, horizon, sunx + ray*cos(r), horizon + ray*sin(r)
   fi
 next
 showpage
 delay 20
wend


Attached File(s) Image(s)
           

B += _
Find all posts by this user
Like Post
08-17-2017, 06:03 AM
Post: #4
 (Print Post)
RE: Sun Spectacular
Awesome!! These screenshots looks GREAT! Big Grin
Find all posts by this user
Like Post



Forum Jump:


User(s) browsing this thread: 1 Guest(s)




QB64 Member Project - Red Scrolling LED Sign
QB64 Member Project - Blokus
QB64 Member Project - Qubic
QB64 Member Project - Exit
QB64 Member Project - Sabotage
QB64 Member Project - STxAxTIC 3D World
QB64 Member Project - Martin Fractals version four
QB64 Member Project - Score 4
QB64 Member Project - Full Color LED Sign
QB64 Member Project - Touche
QB64 Member Project - 9 Board
QB64 Member Project - Kings Valley verion one
QB64 Member Project - Pivot version two
QB64 Member Project - Overboard
QB64 Member Project - Swirl
QB64 Member Project - Dreamy Clock
QB64 Member Project - Martin Fractals version three
QB64 Member Project - Connect Four
QB64 Member Project - Basic Dithering
QB64 Member Project - Martin Fractals version two
QB64 Member Project - Inside Moves
QB64 Member Project - Quarto
QB64 Member Project - Kings Court
QB64 Member Project - Color Rotating Text
QB64 Member Project - Rotating Background
QB64 Member Project - Splatter
QB64 Member Project - Spiro Roses
QB64 Member Project - Isolation
QB64 Member Project - Input
QB64 Member Project - Line Thickness
QB64 Member Project - OpenGL Triangles
QB64 Member Project - Bowditch curve
QB64 Member Project - Kobolts Monopoly
QB64 Member Project - Dakapo
QB64 Member Project - ARB Checkers
QB64 Member Project - Spinning Color Wheel
QB64 Member Project - Algeria Weather
QB64 Member Project - Othello
QB64 Member Project - Foursight
QB64 Member Project - Domain
QB64 Member Project - Rubix's Magic
QB64 Member Project - Martin Fractals version one
QB64 Member Project - Point Blank
QB64 Member Project - Amazon
QB64 Member Project - Color Triangles
QB64 Member Project - Kings Vallery version two
QB64 Member Project - MAPTRIANGLE
QB64 Member Project - RGB Color Wheel
QB64 Member Project - Pivet version one