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


To Independence Day!
07-03-2017, 11:31 PM
Post: #1
 (Print Post)
To Independence Day!
Code Snippet: [Select]
'Psychedelic Star Swirl.bas for FreeBASIC [B+=MGA] 2017-03-15
'from SmallBASIC version 2017-03-01
Randomize Timer
Const As Double PI = ACos(-1)
Const As Double RAD = PI / 180
Common Shared As Double r, g, b, clr
'Set screen size here
dim as integer sw = 600, sh = 600, depth = 32
screenres sw, sh, depth, 2
WindowTitle "Psychedelic Star Swirl  -  Press esc to exit"
sub star( x As Integer, y As Integer, rInner As Double, rOuter As Double, nPoints As Integer, angleOffset As Double)
 ' 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 As Double pAngle, radAngleOffset, x1, y1, x2, y2, x3, y3
 Dim As Integer i
 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 rgb(127 + 127 * sin(r * clr), 127 + 127 * sin(g * clr), 127 + 127 * sin(b * clr))
 If clr > 50000 then r = Rnd(1) : g = Rnd(1): b = Rnd(1) : clr = 0
End Sub
Dim As Integer page, notpage, rd, cx, cy
Dim As Double size, radius, angle, sangle, x, y, r2
Dim ky as String
notpage = 1 : cx = sw/2 : cy = sh/2
sangle = 0.0 : r = Rnd(1) : g = Rnd(1) : b = Rnd(1)
While ky <> Chr(27)
 If page = 0 Then page = 1 ELSE page = 0   'These two lines flip the page and the
   If notpage = 1 THEN notpage = 0 ELSE notpage = 1 'backpage
   SCREENSET page, notpage 'This flips the page
     
   size = 1
   radius = .06
   angle = sangle
   cls
   While radius < 400
     x = cos(angle) * radius
     y = sin(angle) * radius
     r2 = (x ^ 2 + y ^ 2) ^ .5
     size = 4 * r2 ^ .25
     For rd = size to 1 step -10
       chColor
       star cx + x, cy + y, rd/3, rd*1.3, 7, 90
     Next
     angle -= .4
     radius += 1
   Wend
 Sleep(60)
   sangle = sangle + pi/18
   ky = InKey
Wend


Attached File(s) Image(s)
   

.zip  FB Psychedelic Star Swirl.zip (Size: 1.21 KB / Downloads: 3)

B += _
Find all posts by this user
Like Post



Forum Jump:


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




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