Vorlage:ColorSwitch: Unterschied zwischen den Versionen

Aus PokéWiki
Navigation Suche
(Die Seite wurde neu angelegt: „{{#vardefine:first|{{padleft:|1|{{{1|000000}}}}}}}{{#vardefine:second|{{#if:{{#ireplace:{{#var:first}}||{{padleft:|2|{{{1|000000}}}}}}}|{{#ireplace:{{#var:firs…“)
 
(Erlaubt jetzt auch Farben mit Alpha-Werten. Zusätzlich auch die Rechnung angepasst, um ein noch besseres Kontrast-Verhältnis zu ermöglichen)
Zeile 1: Zeile 1:
{{#vardefine:first|{{padleft:|1|{{{1|000000}}}}}}}{{#vardefine:second|{{#if:{{#ireplace:{{#var:first}}||{{padleft:|2|{{{1|000000}}}}}}}|{{#ireplace:{{#var:first}}||{{padleft:|2|{{{1|000000}}}}}}}|{{#var:first}}}}}}{{#vardefine:third|{{#ireplace:{{#var:first}}{{#var:second}}||{{padleft:|3|{{{1|000000}}}}}}}}}{{#vardefine:fourth|{{#ireplace:{{#var:first}}{{#var:second}}{{#var:third}}||{{padleft:|4|{{{1|000000}}}}}}}}}{{#vardefine:fifth|{{#ireplace:{{#var:first}}{{#var:second}}{{#var:third}}{{#var:fourth}}||{{padleft:|5|{{{1|000000}}}}}}}}}{{#vardefine:sixth|{{#ireplace:{{#var:first}}{{#var:second}}{{#var:third}}{{#var:fourth}}{{#var:fifth}}||{{padleft:|6|{{{1|000000}}}}}}}}}{{#vardefine:first|{{#ireplace:A|10|{{#ireplace:B|11|{{#ireplace:C|12|{{#ireplace:D|13|{{#ireplace:E|14|{{#ireplace:F|15|{{#var:first}}}}}}}}}}}}}}}}{{#vardefine:second|{{#ireplace:A|10|{{#ireplace:B|11|{{#ireplace:C|12|{{#ireplace:D|13|{{#ireplace:E|14|{{#ireplace:F|15|{{#var:second}}}}}}}}}}}}}}}}{{#vardefine:third|{{#ireplace:A|10|{{#ireplace:B|11|{{#ireplace:C|12|{{#ireplace:D|13|{{#ireplace:E|14|{{#ireplace:F|15|{{#var:third}}}}}}}}}}}}}}}}{{#vardefine:fourth|{{#ireplace:A|10|{{#ireplace:B|11|{{#ireplace:C|12|{{#ireplace:D|13|{{#ireplace:E|14|{{#ireplace:F|15|{{#var:fourth}}}}}}}}}}}}}}}}{{#vardefine:fifth|{{#ireplace:A|10|{{#ireplace:B|11|{{#ireplace:C|12|{{#ireplace:D|13|{{#ireplace:E|14|{{#ireplace:F|15|{{#var:fifth}}}}}}}}}}}}}}}}{{#vardefine:sixth|{{#ireplace:A|10|{{#ireplace:B|11|{{#ireplace:C|12|{{#ireplace:D|13|{{#ireplace:E|14|{{#ireplace:F|15|{{#var:sixth}}}}}}}}}}}}}}}}{{#vardefine:R|{{#ifexpr:16 * {{#var:first}} + {{#var:second}} <= 128|1|0}}}}{{#vardefine:G|{{#ifexpr:16 * {{#var:third}} + {{#var:fourth}} >= 128|1|0}}}}{{#vardefine:B|{{#ifexpr:16 * {{#var:fifth}} + {{#var:sixth}} <= 255|1|0}}}}{{#ifexpr:({{#var:R}} = 1 or {{#var:G}} = 0) and {{#var:B}} = 1|ffffff|000000}}{{#vardefine:first|}}{{#vardefine:second|}}{{#vardefine:third|}}{{#vardefine:fourth|}}{{#vardefine:fifth|}}{{#vardefine:sixth|}}{{#vardefine:R|}}{{#vardefine:G|}}{{#vardefine:B|}}<noinclude>[[Kategorie:Vorlage]]</noinclude>
+
{{#vardefine:first|{{padleft:|1|{{{1|000000}}}}}}}{{#vardefine:second|{{#if:{{#ireplace:{{#var:first}}||{{padleft:|2|{{{1|000000}}}}}}}|{{#ireplace:{{#var:first}}||{{padleft:|2|{{{1|000000}}}}}}}|{{#var:first}}}}}}{{#vardefine:third|{{#ireplace:{{#var:first}}{{#var:second}}||{{padleft:|3|{{{1|000000}}}}}}}}}{{#vardefine:fourth|{{#ireplace:{{#var:first}}{{#var:second}}{{#var:third}}||{{padleft:|4|{{{1|000000}}}}}}}}}{{#vardefine:fifth|{{#ireplace:{{#var:first}}{{#var:second}}{{#var:third}}{{#var:fourth}}||{{padleft:|5|{{{1|000000}}}}}}}}}{{#vardefine:sixth|{{#ireplace:{{#var:first}}{{#var:second}}{{#var:third}}{{#var:fourth}}{{#var:fifth}}||{{padleft:|6|{{{1|000000}}}}}}}}}{{#vardefine:seventh|{{#ireplace:{{#var:first}}{{#var:second}}{{#var:third}}{{#var:fourth}}{{#var:fifth}}{{#var:sixth}}||{{padleft:|7|{{padright:{{{1|000000}}}|8|F}}}}}}}}{{#vardefine:eighth|{{#ireplace:{{#var:first}}{{#var:second}}{{#var:third}}{{#var:fourth}}{{#var:fifth}}{{#var:sixth}}{{#var:seventh}}||{{padleft:|8|{{padright:{{{1|000000}}}|8|F}}}}}}}}{{#vardefine:first|{{#ireplace:A|10|{{#ireplace:B|11|{{#ireplace:C|12|{{#ireplace:D|13|{{#ireplace:E|14|{{#ireplace:F|15|{{#var:first}}}}}}}}}}}}}}}}{{#vardefine:second|{{#ireplace:A|10|{{#ireplace:B|11|{{#ireplace:C|12|{{#ireplace:D|13|{{#ireplace:E|14|{{#ireplace:F|15|{{#var:second}}}}}}}}}}}}}}}}{{#vardefine:third|{{#ireplace:A|10|{{#ireplace:B|11|{{#ireplace:C|12|{{#ireplace:D|13|{{#ireplace:E|14|{{#ireplace:F|15|{{#var:third}}}}}}}}}}}}}}}}{{#vardefine:fourth|{{#ireplace:A|10|{{#ireplace:B|11|{{#ireplace:C|12|{{#ireplace:D|13|{{#ireplace:E|14|{{#ireplace:F|15|{{#var:fourth}}}}}}}}}}}}}}}}{{#vardefine:fifth|{{#ireplace:A|10|{{#ireplace:B|11|{{#ireplace:C|12|{{#ireplace:D|13|{{#ireplace:E|14|{{#ireplace:F|15|{{#var:fifth}}}}}}}}}}}}}}}}{{#vardefine:sixth|{{#ireplace:A|10|{{#ireplace:B|11|{{#ireplace:C|12|{{#ireplace:D|13|{{#ireplace:E|14|{{#ireplace:F|15|{{#var:sixth}}}}}}}}}}}}}}}}{{#vardefine:seventh|{{#ireplace:A|10|{{#ireplace:B|11|{{#ireplace:C|12|{{#ireplace:D|13|{{#ireplace:E|14|{{#ireplace:F|15|{{#var:seventh}}}}}}}}}}}}}}}}{{#vardefine:eighth|{{#ireplace:A|10|{{#ireplace:B|11|{{#ireplace:C|12|{{#ireplace:D|13|{{#ireplace:E|14|{{#ireplace:F|15|{{#var:eighth}}}}}}}}}}}}}}}}{{#vardefine:A|{{#expr:(((16 * {{#var:seventh}} + {{#var:eighth}}) * 100 / 255) round 0) / 100}}}}{{#vardefine:R|{{#expr:(1 - {{#var:A}}) * 255 + {{#var:A}} * (16 * {{#var:first}} + {{#var:second}})}}}}{{#vardefine:G|{{#expr:(1 - {{#var:A}}) * 255 + {{#var:A}} * (16 * {{#var:third}} + {{#var:fourth}})}}}}{{#vardefine:B|{{#expr:(1 - {{#var:A}}) * 255 + {{#var:A}} * (16 * {{#var:fifth}} + {{#var:sixth}})}}}}{{#ifexpr:(0.2126*{{#var:R}} + 0.7152*{{#var:G}} + 0.0722*{{#var:B}}) >= 128|000000|ffffff}}{{#vardefine:first|}}{{#vardefine:second|}}{{#vardefine:third|}}{{#vardefine:fourth|}}{{#vardefine:fifth|}}{{#vardefine:sixth|}}{{#vardefine:seventh|}}{{#vardefine:eighth|}}{{#vardefine:R|}}{{#vardefine:G|}}{{#vardefine:B|}}{{#vardefine:A|}}

Version vom 17. Februar 2020, 21:35 Uhr

ffffff