[rgb_Row]

Description

Link: [rgb_Row]
Author: Ke Carlton
Category: Output
Version: 8.x
License: Public Domain
Posted: Apr. 16, 2006
Updated: Apr. 16, 2006
More by this author...
This tag generates a colour array that cycles through the colour spectrum and returns a #hex value to represent the current iteration.

You can additionally specify minimum and maximum brightness levels.

Enjoy!

Ke

Parameters

-Max Brightness integer, optional
-Min Brightness integer, optional
-Row Number integer, required
-Total Rows integer, required

Sample Usage

[var:'toloop'=15]
[loop:$toloop]
<span style="background-color:[rgb_row:loop_count,$toloop];">Row: [loop_count]</span><br/>
[/loop]
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
define_tag: 'rgb_row';
	// Returns a transitional colour based on total number of rows and the current row number
	// PARAMS: Row Number, Total Rows, Min Brightness (optional) , Max Brightness (optional)
	//		Example use:
	//			[var:'toloop'=15]
	//			[loop:$toloop]
	//				<span style="background-color:[rgb_row:loop_count,$toloop];">Row: [loop_count]</span><br/>
	//			[/loop]

	if:params->size >= 2;
		local:'row'=params->(get:1);
		local:'count'=params->(get:2);
		if:#count > 360;		
			local:'row' = (math_ceil:#row * (360.00/#count));
			#count = 360;
		/if;
		local:'deg'=360/#count;
		local:'loop'= #count;
		local:'colours'=(array);
		local:'min' = 100;	// Minimum brightness level
		local:'max' = 220;	// Maxium brightness level
		
		params->size >=3 ? #min = params->(get:3); // Overide Minimum Brightness
		params->size >=4 ? #max = params->(get:4); // Overide Maxium Brightness

		local:'r'=(array);
		local:'g'=(array);
		local:'b'=(array);
		local:'c'='';
		
		if:(var_defined:'RBG'+#count);
			#colours = (var:'RBG'+#count);
		else;
			// Generate first hue array
			loop:#loop;
				local:'ang'=#deg*loop_count;
				local:'offset' = 120;
				if:#ang < #offset || #ang >= (#offset+240);
					#c=#min;
				else:#ang >(#offset+60) && #ang < (#offset+240)-60;
					#c=#max;
				else:#ang <=(#offset+60);
					#c=#min+((#max-#min) * ((100.00/60)* (#ang-#offset)*0.01));
				else;
					#c= #min+((#max-#min)* ((100.00/60)*((#offset+240)-#ang)*0.01) );
				/if;
				#c = (math_round:#c,1);
				#c = (math_random:-lower=#c,-upper=#c,-hex);
				#c->size<2?#c='0'+#c;
				#b->(insert:#c);	
			/loop;

			// Cycle for other primarys
			#r = #b;loop:#b->size/3;local:'x' = #r->(get:1);#r->(removefirst);#r->(insertlast:#x);/loop;
			#g = #r;loop:#b->size/3;local:'x' = #g->(get:1);#g->(removefirst);#g->(insertlast:#x);/loop;
			loop:#b->size;#colours->(insert:'#'+#r->(get:loop_count)+#b->(get:loop_count)+#g->(get:loop_count));/loop;
			var:'RBG'+#count = #colours;	// Store colour array for future use
			
		/if;
		
		if:#row <= #colours->size;
			local:'colour' = #colours->(get:#row);
			return:#colour;
		else;
			return:'#FFFFFF';
		/if;		
	/if;
/define_tag;

 

Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net