Thread: Color Cycle
View Single Post
  #1  
Old 05-14-2008, 06:58 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Color Cycle

A simple color cycle. It will turn one number (input) in to a RGB color Graal can understand.

PHP Code:
function ColorCycle(i) {
  
temp.114;
  
temp.max((sin(max(i0) / 12)), 0.01);
  
temp.max((sin(max(160) / 16)), 0.01);
  
temp.max((sin(max(360) / 20)), 0.01);
  return {
rgb};




Example:
PHP Code:
//#CLIENTSIDE
for(temp.0temp.255temp.++) {
  
showimg(200"light2.png"xy);
  
temp.color colorcycle(i);
  
changeimgcolors(200color[0], color[1], color[2], 0.99);
  
sleep(0.05);

The light will cycle through all of the colors of the rainbow.


Another example:
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
showimg(200"light2.png"200200);
  
changeimgvis(2004);
  
onCreateColor();
  
onTimeout();
}

function 
onCreateColor() {
  new 
GuiWindowCtrl("Color_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "90,90";

    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canresize false;
    
closequery false;
    
destroyonhide false;
    
showtop();
    
text "Color";
    
50;
    
50;
    new 
GuiShowImgCtrl("Color_Table") {
      
0;
      
width height 90;
      
image "tig-colortab.png";
    }
    new 
GuiShowImgCtrl("Color_Cursor") {
      
0;
      
image "tig-colorcursor.png";
    }
  }
}

function 
onTimeout() {
  if (
leftmousebuttonglobal) {
    if (
mousescreenx in |Color_Window1.6Color_Window1.Color_Window1.width 5| &&
      
mousescreeny in |Color_Window1.24Color_Window1.Color_Window1.height 5|) {
      
this.mx Color_Table.globaltolocalcoord({mousescreenxmousescreeny});
      
Color_Cursor.this.mx[0] - 6;
      
Color_Cursor.this.mx[1] - 6;
      
temp.color colorcycle(this.mx[0]);
      
changeimgcolors(200color[0], color[1], color[2], 0.99);
    }
  }
  
setTimer(0.05);

(See attachment images for this example)
This script will allow you to select any color you want.
Attached Images
  
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”

Last edited by Tigairius; 05-15-2008 at 04:11 AM..
Reply With Quote