Difference between revisions of "Template:ColorMath"
Jump to navigation
Jump to search
m |
m (Pfft. Should have pressed Preview first. Sorry about that.) |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 13: | Line 13: | ||
| | | | ||
{{#vardefine:hex|{{LSL Hex/Write|{{#expr: | {{#vardefine:hex|{{LSL Hex/Write|{{#expr:{{{1|0}}} mod 256}}|chars=2}}{{LSL Hex/Write|{{#expr:{{{2|0}}} mod 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:y|{{#expr:({{{2|0}}} mod 256) / 255 round {{{round|3}}}}}}} | |||
{{#vardefine:z|{{#expr:({{{3|0}}} mod 256) / 255 round {{{round|3}}}}}}} | |||
}} | }} | ||
{{#vardefine:vector|<{{# | {{#vardefine:padding|{{#expr:{{{round|3}}}+2}}}} | ||
{{#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> | ||
Line 29: | Line 29: | ||
* 2 = g [0, 255] | * 2 = g [0, 255] | ||
* 3 = b [0, 255] | * 3 = b [0, 255] | ||
* hex = | * hex=rrggbb ('''no''' "{{code|#}}" prefix is allowed on this template!) | ||
Output: | Output: | ||
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> |
Latest revision as of 09:28, 14 October 2023
Parameters:
- 1 = r [0, 255]
- 2 = g [0, 255]
- 3 = b [0, 255]
- hex=rrggbb (no "
#
" prefix is allowed on this template!)
Output:
- {{#var:hex}} - html style color integer, without "#"
- {{#var:vector}} - LSL style vector with values [0, 1]
- 001f3f - <0.000, 0.122, 0.247> - 001F3F - <0.000, 0.122, 0.247>