Template:Color: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Doc}}[[Category:Mathematics templates]]
<includeonly><onlyinclude><span style="white-space:nowrap; color:#DDD; user-select:all"><!--
<includeonly><onlyinclude><kbd style="display:inline-flex; flex-direction:row; align-items:baseline; width:fit-content; margin:0 2px; color:lightgrey"><!--


--><kbd style="user-select:none; background:rgb({{{rgb|{{{r|0}}}}}},{{{rgb|{{{g|0}}}}}},{{{rgb|{{{b|0}}}}}}); color:rgb(0,0,0,0); min-width:11px; min-height:11px; border:1px solid #444; border-right:0; padding:0 1px; border-radius:4px 0 0 4px" title="Click to switch between RGB and Hex.">⇆</kbd><!--
------ Color Square


--><kbd style="user-select:all; background-color:rgba(0,0,0,.16); border:1px solid #444; padding:0 2px"><!--
--><span style="display:inline-block; width:8px; height:8px; margin-bottom:-1px; border:1px solid #525252; background:linear-gradient(#000, rgb({{{r|{{{rgb|0}}}}}},{{{g|{{{rgb|0}}}}}},{{{b|{{{rgb|0}}}}}},{{{a|1}}}) 0%), repeating-conic-gradient(#FFF 0 25%,#AAA 0 50%)"></span><!--


--><kbd style="display:inline-flex; align-items:baseline"><!--
------ Arrows Button


--><kbd class=mw-collapsible id=mw-customcollapsible-coltype{{{rgb|{{{r|0}}}}}}{{{rgb|{{{g|0}}}}}}{{{rgb|{{{b|0}}}}}}{{{a|}}}>&#35;{{#switch:{{#expr:floor({{{rgb|{{{r|0}}}}}} / 16)}}|#default={{#expr:floor({{{rgb|{{{r|0}}}}}} / 16)}}
--><span class="mw-customtoggle-color{{{rgb|0}}}{{{r|0}}}{{{g|0}}}{{{b|0}}}{{{a|1}}}" style="margin:0 .3em; user-select:none"><span style="display:inline-block; width:8px; height:10px; margin-bottom:-1px; background:#FFF; clip-path:path('M4 0l4 4H6L4 2 2 4H0m4 6L0 6h2l2 2 2-2h2')"></span></span><!--
|10=A|11=B|12=C|13=D|14=E|15=F
}}{{#switch:{{#expr:{{{rgb|{{{r|0}}}}}} mod 16}}|#default={{#expr:{{{rgb|{{{r|0}}}}}} mod 16}}
|10=A|11=B|12=C|13=D|14=E|15=F
}}{{#switch:{{#expr:floor({{{rgb|{{{g|0}}}}}} / 16)}}|#default={{#expr:floor({{{rgb|{{{g|0}}}}}} / 16)}}
|10=A|11=B|12=C|13=D|14=E|15=F
}}{{#switch:{{#expr:{{{rgb|{{{g|0}}}}}} mod 16}}|#default={{#expr:{{{rgb|{{{g|0}}}}}} mod 16}}
|10=A|11=B|12=C|13=D|14=E|15=F
}}{{#switch:{{#expr:floor({{{rgb|{{{b|0}}}}}} / 16)}}|#default={{#expr:floor({{{rgb|{{{b|0}}}}}} / 16)}}
|10=A|11=B|12=C|13=D|14=E|15=F
}}{{#switch:{{#expr:{{{rgb|{{{b|0}}}}}} mod 16}}|#default={{#expr:{{{rgb|{{{b|0}}}}}} mod 16}}
|10=A|11=B|12=C|13=D|14=E|15=F
}}{{#if:{{{a|}}}|{{#switch:{{#expr:floor((({{{a}}} * 255) round 0) / 16)}}|#default={{#expr:floor((({{{a}}} * 255) round 0) / 16)}}
|10=A|11=B|12=C|13=D|14=E|15=F
}}{{#switch:{{#expr:(({{{a}}} * 255) round 0) mod 16}}|#default={{#expr:(({{{a}}} * 255) round 0) mod 16}}
|10=A|11=B|12=C|13=D|14=E|15=F
}}}}<span style=user-select:none></span></kbd><!--


--><kbd style="display:none" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-coltype{{{rgb|{{{r|0}}}}}}{{{rgb|{{{g|0}}}}}}{{{rgb|{{{b|0}}}}}}{{{a|}}}">{{#if:{{{a|}}}|rgba({{{rgb|{{{r|0}}}}}},{{{rgb|{{{g|0}}}}}},{{{rgb|{{{b|0}}}}}},{{{a}}})|rgb({{{rgb|{{{r|0}}}}}},{{{rgb|{{{g|0}}}}}},{{{rgb|{{{b|0}}}}}})}}<span style=user-select:none></span></kbd><!--
------ HEX Format


--></kbd></kbd><!--
--><samp id="mw-customcollapsible-color{{{rgb|0}}}{{{r|0}}}{{{g|0}}}{{{b|0}}}{{{a|1}}}" class="mw-collapsible">&#35;{{#switch:{{#expr:floor({{{r|{{{rgb|0}}}}}} / 16)}}|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F}}<!--
-->{{#switch:{{#expr:{{{r|{{{rgb|0}}}}}} mod 16}}|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F}}<!--
-->{{#switch:{{#expr:floor({{{g|{{{rgb|0}}}}}} / 16)}}|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F}}<!--
-->{{#switch:{{#expr:{{{g|{{{rgb|0}}}}}} mod 16}}|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F}}<!--
-->{{#switch:{{#expr:floor({{{b|{{{rgb|0}}}}}} / 16)}}|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F}}<!--
-->{{#switch:{{#expr:{{{b|{{{rgb|0}}}}}} mod 16}}|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F}}<!--
-->{{#if:{{{a|}}}|{{#switch:{{#expr:floor((({{{a}}} * 255) round 0) / 16)}}|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F}}<!--
-->{{#switch:{{#expr:(({{{a}}} * 255) round 0) mod 16}}|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=A|11=B|12=C|13=D|14=E|15=F}}}}</samp><!--


--><kbd class="mw-customtoggle-coltype{{{rgb|{{{r|0}}}}}}{{{rgb|{{{g|0}}}}}}{{{rgb|{{{b|0}}}}}}{{{a|}}}" style="user-select:none; background-color:rgba(0,0,0,.16); border:1px solid #444; border-left:0; padding:0 2px; border-radius:0 4px 4px 0" title="Click to switch between RGB and Hex.">⇆</kbd><!--
------ RGB Format


--></kbd></onlyinclude></includeonly>
--><samp id="mw-customcollapsible-color{{{rgb|0}}}{{{r|0}}}{{{g|0}}}{{{b|0}}}{{{a|1}}}" class="mw-collapsible mw-collapsed" style="display:none">rgb({{{r|{{{rgb|0}}}}}},{{{g|{{{rgb|0}}}}}},{{{b|{{{rgb|0}}}}}}{{#if:{{{a|}}}|,{{{a}}}}})</samp><!--
 
--></span></onlyinclude></includeonly>
{{Doc}}
[[Category:Mathematics templates]]

Latest revision as of 18:29, 10 October 2025

English (en)Deutsch (de)Esperanto (eo)Español (es)Français (fr)Suomi (fi)Hrvatski (hr)Magyar (hu)Italiano (it)日本語 (ja)한국어 (ko)Nederlands (nl)Polski (pl)Português (pt)Português do Brasil (pt-br)Русский (ru)Slovenčina (sk)Svenska (sv)Türkçe (tr)Українська (uk)Tiếng Việt (vi)中文 (zh)中文(臺灣) (zh-tw)
Curly brackets white.pngTemplate Documentation [view] [edit]
Icon-translate.png Available doc translations
Page history

Usage

You can click on the arrow icon to change the color display from HEX to RGB and back.

Parameter Description Example Preview
No parameters If no parameters are specified, the template will display black color. {{Color}} #000000
| r = <0-255>
| g = <0-255>
| b = <0-255>
Setting the values ​​of red, green and blue colors respectively. {{Color|r=200|g=128|b=64}} #C88040
| rgb = <0-255> Controls all three colors at once. If a separate color value is specified, it will take precedence. {{Color|rgb=99}}
{{Color|rgb=64|g=255}}
#636363
#40FF40
| a = <0.0-1.0> Alpha channel. {{Color|rgb=80|b=220|a=.6}} #5050DC99
Icon-Bug.pngBug:If the same color is specified on the page, then pressing the arrow button will change the HEX/RGB display for all the same colors at once: #808080 and #808080.