Difference between revisions of "Template:ColorMath"

From Second Life Wiki
Jump to navigation Jump to search
m
m
Line 15: Line 15:
{{#vardefine:hex|{{LSL Hex/Write|{{#expr:({{{1|0}}} mod 256) * 256 * 256}}|chars=2}}{{LSL Hex/Write|{{#expr:({{{2|0}}} mod 256) * 256}}|chars=2}}{{LSL Hex/Write|{{#expr:({{{3|0}}} mod 256)}}|chars=2}}}}
{{#vardefine:hex|{{LSL Hex/Write|{{#expr:({{{1|0}}} mod 256) * 256 * 256}}|chars=2}}{{LSL Hex/Write|{{#expr:({{{2|0}}} mod 256) * 256}}|chars=2}}{{LSL Hex/Write|{{#expr:({{{3|0}}} mod 256)}}|chars=2}}}}


{{#vardefine:x|{{#expr:({{{1|0}}} mod 256) / 255 round {{{round|3}}})}}}}
{{#vardefine:x|{{#expr:({{{1|0}}} mod 256) / 255 round {{{round|3}}}}}}}
{{#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}}}}}}}


}}
}}
Line 36: Line 36:


{{ColorMath|hex=001f3f}} - {{#var:hex}} - {{#var:vector}}
{{ColorMath|hex=001f3f}} - {{#var:hex}} - {{#var:vector}}
{{ColorMath|0|31|63}} - {{#var:hex}} - {{#var:vector}}
</noinclude>
</noinclude>

Revision as of 13:23, 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}}>
- 001F003F - <{{#pad:0.|5|0|right}}, {{#pad:0.122|5|0|right}}, {{#pad:0.247|5|0|right}}>