Colour Cycling

BlitzPlus Forums/BlitzPlus Programming/Colour Cycling

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

ok this is something like that you probly wan't
Graphics 800,600,32,3
Restore colo
Read r1,g1,b1,blah
Read r2,g2,b2,nb
st=0
Repeat
	st=st+1
	col$=gradient(r1,g1,b1,r2,g2,b2,nb,st)
	Color Mid(col$,1,3),Mid(col$,4,3),Mid(col$,7,3)
	Rect 0,0,800,600
	Flip
	If st=nb
		r1=r2
		g1=g2
		b1=b2
		st=0
		Read r2,g2,b2,nb
		If r2=999 And g2=999 And b2=999
			Restore colo	
			Read r2,g2,b2,nb
		EndIf
	EndIf
Until KeyDown(1)
WaitKey
End
;---------------data--------------
;r,g,b,steps
;---------------------------------
.Colo
Data 255,0,0,100
Data 255,100,0,100
Data 255,200,0,100
Data 255,255,0,100
Data 200,255,0,100
Data 100,255,0,100
Data 0,255,0,100
Data 0,255,100,100
Data 0,200,200,100
Data 0,100,255,100
Data 0,0,255,100
Data 100,0,255,100
Data 200,0,200,100
Data 255,0,100,100
Data 999,999,999,999 ; end of data

;-------------function gradient-----------
; return a string in format rrr,ggg,bbb
;-----------------------------------------
;
;rs#,gs#,bs# :rgb source
;re#,ge#,be# :rgb destination
;stpg steps for the total transition
;cs current step
;
;
Function gradient$(rs#,gs#,bs#,re#,ge#,be#,stpg,cs)
	If rs#>re#
		vadr#=((rs#-re#)/stpg)*-1.0
	Else
		vadr#=((re#-rs#)/stpg)*1.0
	EndIf
	If rs#>re#
		vadg#=((gs#-ge#)/stpg)*-1.0
	Else
		vadg#=((ge#-gs#)/stpg)*1.0
	EndIf
	If bs#>be#
		vadb#=((bs#-be#)/stpg)*-1.0
	Else
		vadb#=((be#-bs#)/stpg)*1.0
	EndIf
	rs#=rs#+vadr#*cs
	gs#=gs#+vadg#*cs
	bs#=bs#+vadb#*cs
	Return Mid$("000",1,3-Len(Str$(Int(rs#))))+Str$(Int(rs#))+Mid$("000",1,3-Len(Str$(Int(gs#))))+Str$(Int(gs#))+Mid$("000",1,3-Len(Str$(Int(bs#))))+Str$(Int(bs#))
End Function



hope you like :)