Difference between revisions of "Template:ColorMath"

From Second Life Wiki
Jump to navigation Jump to search
m
(Replace deprecated ParserFunctions "#pad" with built-in "Magic word" "padleft")
Line 22: Line 22:


{{#vardefine:padding|{{#expr:{{{round|3}}}+2}}}}
{{#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}}>}}
{{#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>

Revision as of 02:05, 20 August 2023

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 - <{{#padright:0.|5|0}}, 0.122, 0.247>
- 001F3F - <{{#padright:0.|5|0}}, 0.122, 0.247>