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 rounding {{{round|3}}})}}, {{#expr:(({{#var:int}} / 256 ) mod 256) / 255 rounding {{{round|3}}})}}, {{#expr:({{#var:int}} mod 256) / 255 rounding {{{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}}})}}>}}


|
|
Line 13: Line 13:
{{#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:vector|<{{#expr:({{{1|0}}} mod 256) / 255 rounding {{{round|3}}})}}, {{#expr:({{{2|0}}} mod 256) / 255 rounding {{{round|3}}})}}, {{#expr:({{{3|0}}} mod 256) / 255 rounding {{{round|3}}})}}>}}
{{#vardefine:vector|<{{#expr:({{{1|0}}} mod 256) / 255 round {{{round|3}}})}}, {{#expr:({{{2|0}}} mod 256) / 255 round {{{round|3}}})}}, {{#expr:({{{3|0}}} mod 256) / 255 round {{{round|3}}})}}>}}


}}}}<noinclude>
}}}}<noinclude>
Line 25: Line 25:
* <nowiki>{{#var:hex}}</nowiki> - html style color integer, without "#"
* <nowiki>{{#var:hex}}</nowiki> - html style color integer, without "#"
* <nowiki>{{#var:vector}}</nowiki> - LSL style vector with values [0, 1]
* <nowiki>{{#var:vector}}</nowiki> - LSL style vector with values [0, 1]
{{ColorMath|hex=001f3f}} - {{#var:hex}} - {{#var:vector}}
</noinclude>
</noinclude>

Revision as of 14:00, 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 - <Expression error: Unexpected closing bracket., Expression error: Unexpected closing bracket., Expression error: Unexpected closing bracket.>