Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Color Color Shifter  

Color Shifter

Color shifter for dance floors, makes a bunch of linked prims very colorful

Category: Color
By : ferd Frederix
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life

the Zip file

Download all files for Color Shifter
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Color Shifter.lsl
1
2
3 // Color shifter for dance floors, makes a bunch of linked prims very colorful
4
5 list colCom ; // an empty list we will fill up with color vectors
6 integer position = 0; // the first position in the list = 0
7
8 default
9 {
11 {
12 // Here I set up three start and 3 end color schemes in a list, which must be done in pairs.
13 // You can add as many as you want. I picked 3 cuz i am lazy
14 //
15 // syntax is always <RED,GREEN,BLUE>, in 0 to 255 decimal numbers.
16 // If this bothers you, try just multiplying by 255 to get the equivalent.
17 // so 50% red, 25% green, and 10 blue = 0.5, 0.25, 0.1, or multiplied by 255 = 128, 64, 25, which is entered as <128,64,25>
18 // This is the same as the color numbers in the Texture Window in SL.
19
20 // first color pair
21 colCom += <255,0,0>; // start with 100% = 255 red
22 colCom += <0,0,255>; // go to all blue
23
24 // color pair
25 colCom += <0,0,255>; // start with all blue
26 colCom += <0,255,0>; // end with all green
27
28
29 // color pair
30 colCom += <0,255,0>; // start with 100% = 255 green
31 colCom += <255,0,0>; // now back to red. It will repeat after that starting with step #1, all red
32
33 // you can use partial colors, too. White = <255,255,255>, black = <0,0,0>, light cyan = <0,128,128>, and so on.
34
35 // the list colCom now contains 6 vectors
36
37 llSetTimerEvent(5.0); //wait 5 seconds, then change color
38 }
39
40 timer ()
41 {
42 vector startCol = llList2Vector(colCom,position); // get the vector on the list colCom pointed to by 'position'
43 vector endCol = llList2Vector(colCom,position+1); // get the next one for end color
44 vector grades = <(endCol.x - startCol.x)/llGetNumberOfPrims(), (endCol.y - startCol.y)/llGetNumberOfPrims(), (endCol.z - startCol.z)/llGetNumberOfPrims()>;
45 // grades is a vector of 3 numbers represeting the difference added each time to fade the color
46 // each color bit, the <Reg,Green.Blue> is now the difference between start and end color as a percentage of the number of prims
47
48 // scan over each prim and make the changes from start to end using the percentage change in 'grades'
49 integer x;
50 for(x = 1; x < llGetNumberOfPrims()+ 1; x++)
51 {
52 startCol += grades; // add the delta we calculated above to a start color
53 llSetLinkColor(x, startCol, ALL_SIDES); // and set the color
54 }
55
56 // now we need to get the next color scheme
57 position += 2; // advance to the next position in the list, which is two steps up, not one
58
59 // llGetListLength returns the number 3 in my demo, we need to check against the numbers 0,1,2 as lists are zero-based, so I check for >=, not just greater than.
60 if(position >= llGetListLength(colCom))
61 {
62 position = 0; // reset to beginning if past the 3rd item (as in 0,1,2)
63 }
64
65 } // end timer
66
67 }// end program

Back to the Best Free Tools in Second Life and OpenSim.