32

This is an **experimental **piece i tinkered with a few years ago, hardly worth being called art.

It uses a rocking motion of sins and cos. eg. -1 to 1 to -1 to 1 etc

1. compile fullscreen 1920x1080

2. dont forget to grab this background image, or the special effect at the end will not look right.

`// --------------------------------- //`

// Project: ColorPalette

// Start: Saturday, August 08, 2015

// IDE Version: 12.312

// compile 1920 x 1080 resolution fullscreen

LOADSPRITE "sky2.png", 9999

WHILE TRUE

STATIC a# = 0

a# = a# + 0.1

IF a# > 359.0

a# = 0.0

ENDIF

b# = SIN(a#) * 127.0

// the meters - still experimenting with colors..these are read to go...they have inputs [0.0..1.0] or [-1.0..1.0]

METER_Volume(30,40,20,300,SIN(a/2))

METER_SINE(60,40,20,300,SIN(a) )//, 0x604020, 0x707070)

METER_SINE(90,40,20,300,COS(b) )//, 0x604020, 0x707070)

// stars

DrawStar(200,500, 0xffffff, 5 , -50 , a , 0.5)

DrawStar(300,600, 0xff00ff, 5 , -100 , a , 0.75)

DrawStar(200,640, 0x808080 + RGB(COS(a)*127,128,0), 24 , -128 , 0 , SIN(a) * 1.0)

DrawStar(200,640, 0x808080 + RGB(0,COS(a)*127,128), 24 , -128 , a , 0.2)

// fractal sun

// this one needs HEAVY experimenting!

MakeSun(960,540, 2048, 2048+COS(b)*2048, 1, RGB( (127+COS(b*10)*127), (127+SIN(b*10)*127),COS(b*5)*127+127), 0x000000, b#, 0.1) //this is the fractal...its a lil messy

IF (GETTIMERALL() >20000)

c=c+0.01

IF c>1.0 THEN c=1.0

DrawStar( 940, 540, 0xffffff, 5, 9999, a, c)

ENDIF

IF (GETTIMERALL() >24000) THEN END

SHOWSCREEN

WEND

//

FUNCTION MakeSun: x1%, y1%, Points2%, Size2%, Wander%, Color#, Color2#, Angle#, Depth#

DrawStar(x1% , y1%+2 , Color#, Points2%, -Size2% , COS(Angle#)*2.0, Depth#)

DrawStar(x1% , y1% , Color2#, Points2% , -Size2% , 0 , Depth#)

RETURN 0

ENDFUNCTION

FUNCTION METER_SINE: x%, y%, w%, h%, Level#, Color1% = 0x00f0f0, Color2% = 0xf0f000 // Level# = -1.0 to 1.0 eg. [-1.0..1.0]

IF Level# < -1.0 THEN Level# = -1.0

IF Level# > 1.0 THEN Level# = 1.0

PRINT Level,10,10

LOCAL MeterLevel# = (h% - 1 ) * Level#

POLYVECTOR x%,y%,w%,h%,0x0000f0

DRAWRECT x%+2,y%+2,w%-4,h%-4,Color2%

DRAWRECT x%+4,y%+4,w%-8,h%-8,Color2% * 0.4

DRAWRECT x%+4,y%+(h%/2),w%-8,-MeterLevel#/2,Color1%

RETURN 0

ENDFUNCTION

FUNCTION METER_Volume: x%, y%, w%, h%, Level#, Color1% = 0x806040, Color2% = 0xf0f000 //Level# = 0 to 1.0 [0..1]

IF Level# < 0 THEN Level# = 0

IF Level# > 1.0 THEN Level# = 1.0

PRINT Level,10,10

LOCAL MeterLevel# = ( h% - 4 ) * Level#

DRAWRECT x%,y%,w%,h,Color1%

DRAWRECT x%+4,y%+4,w%-8,h%-9,Color1% * 0

DRAWRECT x%+4,y%+h%-4,w%-8,-MeterLevel#, Color2%

RETURN 0

ENDFUNCTION

FUNCTION DrawStar: x%, y%, Color#, NumberOfPoints%, TextureID%, Rotate#, Depth# // make some stars! -TextureID# = SIZE If No Sprites ID is supplied. (-) Negative ID

// Star Creator Code Designed Neil M. Silver, Aug. 9, 2015

//

// The Algorithm:

// --

// NumberOfPoints = Number of visually obvious points, eg. An American Star is 5 pointed.

// --

// Vector Count = The number of actual vectors a polyvector needs, in fan mode, can be calculated:

//

// ( V = P * 2 + 2 )

// VectorCount% = ( NumberOfPoints% * 2 ) + 2 )

// Note: Add Two, one for the center point, one for the last point.

// --

// VectorAngleSize% = is the turn size for each vector to draw.

// ( A = 180 / P )

// VectorAngleSize# = ( 180.0 / NumberOfPoints% )

// --

// Depth%

// The inner and outer radius represent the length of the points, and the depth of thier inner corners.

// The Depth% value is a scalar, a ratio of the outer radius, 0.5 is good for stars...play with this [0.1~~1.0]

//

// . ________________

// ^

// . . . . | Outer Radius

// V

// . ________________

// V Inner Radius (Depth#)

// . ______________

// . .

//

//

// --

// Rotate%, 360 degrees

// --

// A negative value for TextureID% will make the star that size, without an image.

// eg ( TextureID% = -5 ) will make the star 10 wide, radius 5...no skin.

// --

//

// Other notes:

// Its midhandled.

// Use a square image, root 2

//

STATIC Phase%

LOCAL iW%, iH%, ViR#, VoR#

LOCAL VectorCount% = ( ( NumberOfPoints% * 2 ) + 2 )

LOCAL VectorAngleSize# = ( 180.0 / NumberOfPoints% ) * 1.0

LOCAL tX#, tY#, vX#, vY#

// Get the outer radius:

IF TextureID% >= 0

GETSPRITESIZE TextureID%, iW%, iH%

ViR# = ( iW% * 0.5 ) * Depth#

VoR# = ( iW% * 0.5 ) * 1.0

ELSE

VoR# = ABS(TextureID%) //use -textureid for a size param

ViR# = ( VoR# * Depth# )

ENDIF

//STAR:

STARTPOLY TextureID%, 0 // FAN Mode only!

POLYVECTOR x%, y%, VoR#, VoR#, Color# // center vector

LOCAL AngleNow#

FOR i% = 0 TO VectorCount% - 1

AngleNow# = ( ( VectorAngleSize# * i% * 1.0 ) + Rotate# ) * 1.0

Phase% = Phase% + 1

IF Phase% > 1

Phase% = 0

ENDIF

IF Phase%

vX# = COS( AngleNow# ) * VoR#

vY# = SIN( AngleNow# ) * VoR#

ELSE

vX# = COS( AngleNow# ) * ViR#

vY# = SIN( AngleNow# ) * ViR#

ENDIF

tX# = vX# + VoR#

tY# = vY# + VoR#

POLYVECTOR x% + vX#, y% + vY#, tX#, tY#, Color#

NEXT

ENDPOLY

RETURN 0

ENDFUNCTION