Template talk:ColorMath

From Second Life Wiki
Jump to navigation Jump to search

Hex numbers must not include the hash prefix!

As of April 2022, I noticed that the page has lots of 'garbage' instead of properly-done ColorMath. I first thought that prefixing the hex value with # (since the template page says that the hash symbol is 'optional') might fix it, but no — it makes everything even worse, since the ColorMath template breaks when it finds that # prefix!

I'd guess this should be tested. Here are my own experiments:

Example 1:

{{ColorMath|hex=f0f1f2}}
{{#var:vector}}

Result:

<0.941, 0.945, 0.949>

Should show:

<{{#pad:0.941|5|0|right}}, {{#pad:0.945|5|0|right}}, {{#pad:0.949|5|0|right}}>

Example 2:

{{ColorMath|hex=#f0f1f2}}
{{#var:vector}}

Result:

<Expression error: Unexpected < operator., Expression error: Unexpected < operator., Expression error: Unexpected < operator.>

Expected (when fixed):

<{{#pad:0.941|5|0|right}}, {{#pad:0.945|5|0|right}}, {{#pad:0.949|5|0|right}}>

... but instead throws three Expression error: Unexpected < operator. errors, as of April 2022.


Gwyneth Llewelyn (talk) 10:57, 6 April 2022 (PDT)

More testing, 18 months later (or so)

Testing:

{{ColorMath|hex=f1f1f1}}
{{#var:vector}}

Result:

<0.945, 0.945, 0.945>


Hmm. Not quite there yet; I still get <{{#padright:0.945|5|0}}, 0.945, 0.945> as a reply. #padright seems to be broken?

Ok. If you see <0.945, 0.945, 0.945>, then it means that I've somehow managed to fix things! Whew.

Note that hex values should never have a # prefixing them, or havoc will follow.

Gwyneth Llewelyn (talk) 10:20, 14 October 2023 (PDT)