Difference between revisions of "Template:ColorMath"

From Second Life Wiki
Jump to navigation Jump to search
(Replace deprecated ParserFunctions "#pad" with built-in "Magic word" "padleft")
m (Pfft. Should have pressed Preview first. Sorry about that.)
 
(2 intermediate revisions by the same user not shown)
Line 22: Line 22:


{{#vardefine:padding|{{#expr:{{{round|3}}}+2}}}}
{{#vardefine:padding|{{#expr:{{{round|3}}}+2}}}}
{{#vardefine:vector|<{{#padright:{{#var:x}}{{#ifexpr:{{#len:{{#var:x}}}} = 1|.}}|{{#var:padding}}|0}}, {{padright:{{#var:y}}{{#ifexpr:{{#len:{{#var:y}}}} = 1|.}}|{{#var:padding}}|0}}, {{padright:{{#var:z}}{{#ifexpr:{{#len:{{#var:z}}}} = 1|.}}|{{#var:padding}}|0}}>}}
{{#vardefine:vector|<{{padright:{{#var:x}}{{#ifexpr:{{#len:{{#var:x}}}} = 1|.}}|{{#var:padding}}|0}}, {{padright:{{#var:y}}{{#ifexpr:{{#len:{{#var:y}}}} = 1|.}}|{{#var:padding}}|0}}, {{padright:{{#var:z}}{{#ifexpr:{{#len:{{#var:z}}}} = 1|.}}|{{#var:padding}}|0}}>}}


}}<noinclude>
}}<noinclude>
Line 29: Line 29:
* 2 = g [0, 255]
* 2 = g [0, 255]
* 3 = b [0, 255]
* 3 = b [0, 255]
* hex = #rrggbb - "#" is optional
* hex=rrggbb ('''no''' "{{code|#}}" prefix is allowed on this template!)


Output:
Output:

Latest revision as of 09:28, 14 October 2023

Parameters:

  • 1 = r [0, 255]
  • 2 = g [0, 255]
  • 3 = b [0, 255]
  • hex=rrggbb (no "#" prefix is allowed on this template!)

Output:

  • {{#var:hex}} - html style color integer, without "#"
  • {{#var:vector}} - LSL style vector with values [0, 1]
- 001f3f - <0.000, 0.122, 0.247>
- 001F3F - <0.000, 0.122, 0.247>