Ooops
March 01, 2021, 10:39:18 PM

Author Topic: [bb] ColourCycling by _PJ_ [ 1+ years ago ]  (Read 533 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] ColourCycling by _PJ_ [ 1+ years ago ]
« on: June 29, 2017, 12:28:42 AM »
Title : ColourCycling
Author : _PJ_
Posted : 1+ years ago

Description : 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.


Code :
Code: BlitzBasic
  1. Graphics3D 800,600,32,0
  2. SetBuffer BackBuffer()
  3.  
  4. SeedRnd MilliSecs()
  5.  
  6. Global Redcol
  7. Global Greencol
  8. Global Bluecol
  9.        
  10.         redend=Rand(256)
  11.         greenend=Rand(256)
  12.         blueend=Rand(256)
  13.        
  14.  
  15. While Not KeyDown(1)
  16.                
  17.                 cycle_colours(redcol,greencol,bluecol,redend,greenend,blueend)
  18.  
  19.                 Color Redcol,Greencol,bluecol
  20.                         Rect 200,150,400,300,1
  21.                 Color 256-Redcol,256-greencol,256-bluecol
  22.                         Rect 350,250,100,100,1                 
  23.                        
  24.        
  25.         If redcol=redend And greencol=greenend And bluecol=blueend
  26.                         redend=Rand(256)
  27.                         greenend=Rand(256)
  28.                         blueend=Rand(256)
  29.         EndIf
  30.  
  31. Flip
  32.  
  33. Wend
  34.                
  35. Function cycle_colours(red1,green1,blue1,red2,green2,blue2)
  36.  
  37.         Redcol=Red1+(Sgn(red2-red1))
  38.         Greencol=Green1+(Sgn(green2-green1))
  39.         Bluecol=blue1+(Sgn(blue2-blue1))
  40.                
  41. End Function


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal