Difference between revisions of "Template:ColorMath"

From Second Life Wiki
Jump to navigation Jump to search
m
m
Line 7: Line 7:
{{#vardefine:int|{{LSL Hex/Parse|{{#var:hex}}}}}}
{{#vardefine:int|{{LSL Hex/Parse|{{#var:hex}}}}}}


{{#vardefine:vector|<{{#expr:(({{#var:int}} / 256 / 256) mod 256) / 255 round {{{round|3}}})}}, {{#expr:(({{#var:int}} / 256 ) mod 256) / 255 round {{{round|3}}})}}, {{#expr:({{#var:int}} mod 256) / 255 round {{{round|3}}})}}>}}
{{#vardefine:vector|<{{#expr:(({{#var:int}} / 256 / 256) mod 256) / 255 round {{{round|3}}}}}, {{#expr:(({{#var:int}} / 256 ) mod 256) / 255 round {{{round|3}}}}}, {{#expr:({{#var:int}} mod 256) / 255 round {{{round|3}}}}}>}}


|
|

Revision as of 14:01, 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 - <0, 0.122, 0.247>