Random Color Text

Expired

Two versions. First is for single prims, second for multiple linked prims.

 

default 
{
    state_entry() 
    {
        llSetTimerEvent(2.0); // every 2 seconds
    }

    timer() 
    {
        llSetColor(, ALL_SIDES);
    }
}

 

 

default 
{
    state_entry() 
    {
        llSetTimerEvent(2.0); // every 2 seconds
    }

    timer() 
    {
        llSetLinkColor(LINK_SET, , ALL_SIDES);
    }
}

 

Random Color Text

Expired

string text = "Here is my Floating Text!";

default 
{
    state_entry() 
    {
        llSetTimerEvent(2.0); // every 2 seconds
        llSetText(text, <1 ,1,1>, 1.0);
    }

    timer() 
    {
        vector newcolor = ;
        llSetText(text, newcolor, 1.0);
    }
}

 

Color Menu

Expired

Select color from 59 choices by menu. Can be used with single prim or multiple prims.

 

// Default is to make the entire object change color, even if multiple prims.
integer ChangeAllPrims = TRUE; // set this to FALSE for this prim only

//-----START COLORS-----------------------------

list grayscale =["black",<0,0,0>,"white",<1 ,1,1>,"gray",<0.5,0.5,0.5>,"silver",<0.75,0.75,0.75>,"darkgray",<0.4,0.4,0.4>,
    "lightgrey",<0.83,0.83,0.83>];
list reds = ["red",<1 ,0,0>,"darkred",<0.55,0,0>,"crimson",<0.86,0.08,0.24>,"indianred",<0.8,0.36,0.36>,
    "orangered",<1 ,0.27,0>];
list pinks = ["hotpink",<1 ,0.41,0.71>,"pink", <1 ,0.75,0.8>,"lightpink",<1 ,0.71,0.76>,"deeppink",<1 ,0.08,0.58>,
    "fuchsia",<1 ,0,1>,"orchid",<0.85,0.44,0.84>,"plum",<0.87,0.63,0.87>];
list violets = ["violet",<0.8,0.51,0.8>,"indigo",<0.29,0,0.51>,"lavender",<0.7,0.7,1>,"magenta",<1 ,0,1>,
    "purple",<0.5,0,0.5>,"darkmagenta",<0.55,0,0.55>,"darkviolet",<0.58,0,0.83>,"blueviolet",<0.54,0.17,0.89>];
list dk_blues = ["darkblue",<0,0,0.55>,"blue",<0,0,1>,"deepskyblue",<0,0.75,1>,"mediumblue",<0,0,0.8>,
    "midnightblue",<0.1,0.1,0.44>,"royalblue",<0.25,0.41,0.88>,"slateblue",<0.42,0.35,0.8>,"steelblue",<0.27,0.51,0.71>];
list lt_blues = ["teal",<0,0.5,0.5>,"turquoise",<0.25,0.88,0.82>,"darkcyan",<0,0.55,0.55>, "lightblue", <0.68,0.85,0.9>,
    "aquamarine",<0.5,1,0.83>,"azure",<0.8,1,1>,"cyan",<0,1,0.9>,"skyblue",<0.53,0.81,0.92>];
list yellows = ["yellow",<1 ,1,0>,"gold",<1 ,0.84,0>,"lightyellow",<1 ,1,0.88>,"goldenrod",<0.85,0.65,0.13>,
    "yellowgreen",<0.6,0.8,0.2>];
list dk_greens = ["darkgreen",<0,0.39,0>,"green",<0,0.5,0>,"forestgreen",<0.13,0.55,0.13>,"lawngreen",<0.49,0.99,0>,
    "springgreen",<0,1,0.5>];
list lt_greens = ["lightgreen",<0.56,0.93,0.56>,"chartreuse",<0.5,1,0>,"greenyellow",<0.68,1,0.18>,"honeydew",<0.94,1,0.94>,
    "limegreen",<0.2,0.8,0.2>,"mintcream",<0.96,1,0.98>,"seagreen",<0.18,0.55,0.34>];
list oranges = ["orange",<1 ,0.65,0>,"darkorange",<1 ,0.55,0>,"coral",<1 ,0.5,0.31>,"navajowhite",<1 ,0.87,0.68>,
    "salmon",<0.98,0.5,0.45>,"seashell",<1 ,0.96,0.93>,"brown",<.24,.17,.15>];

//-----END COLORS-----------------------------

key toucher = NULL_KEY;
list sub_menu;
list main_menu = ["grayscale", "reds", "pinks", "violets", "dk_blues", "lt_blues", "yellows", "dk_greens", "lt_greens", "oranges"];



//FUNCTIONS

//owner menu
integer menu_handler;
integer menu_channel;
menu(key user,string title,list buttons)
{
    llListenRemove(menu_handler);
    menu_channel = (integer)(llFrand(99999.0) * -1);
    menu_handler = llListen(menu_channel,"","","");
    llDialog(user,title,buttons,menu_channel);
    llSetTimerEvent(60.0);
}

default
{
    on_rez( integer sparam )
    {
        llResetScript();
    }
    
    state_entry()
    {
        //
    }
    
    touch_start(integer total_number)
    {
        toucher = llDetectedKey(0);
        menu(toucher, "\n \nSelect a color category.", main_menu);
    }

    // use link message instead of touch in case you have more menu in another script.
    //link_message(integer sender_num, integer num, string str, key id)
    //{
        //if (str == "Colors") // from main script
        //{
            //toucher = id;
            //menu(toucher, "\n \nSelect a color category.", main_menu);
        //}
    //}
    
    timer() 
    {
        llSetTimerEvent(0.0);
        llListenRemove(menu_handler);
        toucher = NULL_KEY;
    }
    
    listen(integer channel, string name, key is, string message)
    {
        if (channel == menu_channel)
        {
            llSetTimerEvent(0.0);
            llListenRemove(menu_handler);
            
            if (llListFindList(main_menu, [message]) != -1) {
            if (message == "grayscale") sub_menu = grayscale; 
            else if (message == "reds") sub_menu = reds;
            else if (message == "pinks") sub_menu = pinks;
            else if (message == "violets") sub_menu = violets;
            else if (message == "dk_blues") sub_menu = dk_blues;
            else if (message == "lt_blues") sub_menu = lt_blues;
            else if (message == "yellows") sub_menu = yellows;
            else if (message == "dk_greens") sub_menu = dk_greens;
            else if (message == "lt_greens") sub_menu = lt_greens;
            else if (message == "oranges") sub_menu = oranges;
            
            menu(toucher, "\n \nSelect a color.", llList2ListStrided(sub_menu, 0, -1, 2));
            return;  
            }
        
            integer index = llListFindList(sub_menu, [message]);
            if (index != -1)
            {
                vector color_vector = llList2Vector(sub_menu, index+1);
                if (ChangeAllPrims == TRUE)
                {
                    llSetLinkColor(LINK_SET, color_vector, ALL_SIDES); //all prims
                }
                else
                {
                    llSetColor(color_vector, ALL_SIDES); //only prim script is in
                }
            }
        }
    }
}

 

Color Scripts

Expired

The following can be used to convert an HSB (HSV, HSL) vector into an RGB vector:

 

// Checks the limits of a single component.
float checkComp(float v, float t1, float t2)
{
    if (v <0.0)
        v = v + 1.0;
        
    if (v > 1.0)
        v = v - 1.0;
        
    if ((v * 6) <1)
        v = t1 + (t2 - t1) * 6.0 * v;
    else
    {
        if ((v * 2.0) < 1.0)
            v = t2;
        else
        {
            if ((v * 3.0) < 2.0)
                v = t1 + (t2 - t1) * ((2.0 / 3.0) - v) * 6.0;
            else
                v = t1;
        }
    }
        
    return v;
}

// Converts an HSB (HSV) colorspace to RGB colorspace
// Input is a vector:
//   x == hue (0 .. 359.9)
//   y == saturation (0 .. 1)
//   z == bright (value, lum) (0 .. 1)
// Output is a vector:
//   x == red (0 .. 1)
//   y == green (0 .. 1)
//   z == blue (0 .. 1)
vector hsb2rgb(vector hsb)
{
    vector rval;
    integer i;
    float t1;
    float t2;
    
    hsb.x /= 360.0;
    
    if (hsb.y == 0.0)
    {
        rval.x = hsb.z;
        rval.y = hsb.z;
        rval.z = hsb.z;
    }
    else
    {
        if (hsb.z < 0.5)
            t2 = hsb.z * (1.0 + hsb.y);
        else
            t2 = hsb.z + hsb.y - hsb.z * hsb.y;
            
        t1 = 2 * hsb.z - t2;
        
        rval.x = checkComp(hsb.x + (1.0 / 3.0), t1, t2);
        rval.y = checkComp(hsb.x, t1, t2);
        rval.z = checkComp(hsb.x - (1.0 / 3.0), t1, t2);
    }
    
    return rval;
}

 

 

Following can be used to convert an RGB vector to HSB:

 

// Converts an RGB colorspace to HSB colorspace
// Input is a vector:
//   x == red (0 .. 1)
//   y == green (0 .. 1)
//   z == blue (0 .. 1)
// Output is a vector:
//   x == hue (0 .. 359.9)
//   y == saturation (0 .. 1)
//   z == bright (value, lum) (0 .. 1)
vector rgb2hsb(vector rgb)
{
    vector rval;
    float min;
    float max;
    float h;
    float d;
    
    min = rgb.x;
    max = rgb.x;
    
    if (rgb.y  max)
        max = rgb.y;
    if (rgb.z > max)
        max = rgb.z;
        
    h = 0;
    rval.z = (max + min) / 2.0;
    
    d = max - min;
    
    if (max == min)
        rval.y = 0.0;
    else
    {
        if (rval.z <0.5)
            rval.y = (max - min) / (max + min);
        else
            rval.y = (max - min) / (2.0 - max - min);
    }
        
    if (d != 0.0)
    {
        if (rgb.x == max)
            h = (rgb.y - rgb.z) / d;
        else if (rgb.y == max)
            h = 2.0 + (rgb.z - rgb.x) / d;
        else
            h = 4.0 + (rgb.x - rgb.y) / d;
    }
    
    h /= 6.0;
    if (h < 0.0)
        h = h + 1.0;
        
    rval.x = h * 360.0;
    
    return rval;
}