Difference between revisions of "Template:ColorMath"

From Second Life Wiki
Jump to navigation Jump to search
m
m
Line 18: Line 18:
{{#vardefine:y|{{#expr:({{{2|0}}} mod 256) / 255 round {{{round|3}}})}}}}
{{#vardefine:y|{{#expr:({{{2|0}}} mod 256) / 255 round {{{round|3}}})}}}}
{{#vardefine:z|{{#expr:({{{3|0}}} mod 256) / 255 round {{{round|3}}})}}}}
{{#vardefine:z|{{#expr:({{{3|0}}} mod 256) / 255 round {{{round|3}}})}}}}


}}
}}


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


}}<noinclude>
}}<noinclude>

Revision as of 13:20, 17 August 2014

Parameters:

  • 1 = r [0, 255]
  • 2 = g [0, 255]
  • 3 = b [0, 255]
  • hex = #rrggbb - "#" is optional

Output:

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