Code archives/Graphics/ColourCycling

This code has been declared by its author to be Public Domain code.

Download source code

ColourCycling by _PJ_2007
This is very basic code with great possibilities. So long as you have the RGB values for the initial (or currrent) colour, and the values for the destined colour, each call to the function gradually changes the colour to the next.

Not recommended for FadeToBlack, as it may be too slow for all colours, depending on system speed and frequency of function call.
Graphics3D 800,600,32,0
SetBuffer BackBuffer()

SeedRnd MilliSecs()

Global Redcol
Global Greencol
Global Bluecol
	
	redend=Rand(256)
	greenend=Rand(256)
	blueend=Rand(256)
	

While Not KeyDown(1)
		
		cycle_colours(redcol,greencol,bluecol,redend,greenend,blueend)

		Color Redcol,Greencol,bluecol
			Rect 200,150,400,300,1
		Color 256-Redcol,256-greencol,256-bluecol
			Rect 350,250,100,100,1			
			
	
	If redcol=redend And greencol=greenend And bluecol=blueend
			redend=Rand(256)
			greenend=Rand(256)
			blueend=Rand(256)
	EndIf

Flip

Wend
		
Function cycle_colours(red1,green1,blue1,red2,green2,blue2)

	Redcol=Red1+(Sgn(red2-red1))
	Greencol=Green1+(Sgn(green2-green1))
	Bluecol=blue1+(Sgn(blue2-blue1))
		
End Function

Comments

None.

Code Archives Forum