Difference between revisions of "Template:Colort/Color"
imported>Jacobolus (kill the bold color names) |
imported>DePiep |
||
| (41 intermediate revisions by 11 users not shown) | |||
| Line 3: | Line 3: | ||
</noinclude> | </noinclude> | ||
|- | |- | ||
| − | + | {{Colort/{{#if:{{{narrow|}}}|2|1}}row | |
| − | + | |code={{{code|{{#if:{{{link|}}}|{{{html_name|{{{name|{{{alias|}}}}}}}}}|rgb({{{r|0}}},{{{g|0}}},{{{b|0}}})}}}}} | |
| − | | | + | |name={{#if:{{{sort|}}}|{{sort|{{{sort}}}|{{#if:{{{link|}}}|[[{{{link}}}|{{{name}}}]]|{{{name}}}}} }}|{{#if:{{{link|}}}|[[{{{link}}}|{{{name|''no name''}}}]]|{{{name|''no name''}}}}} }} |
| − | | | + | |r={{{r|0}}} |
| − | | | + | |g={{{g|0}}} |
| − | | | + | |b={{{b|0}}} |
| − | | | + | |red={{#expr:{{{r|0}}}/2.55 round 0}} |
| − | | | + | |green={{#expr:{{{g|0}}}/2.55 round 0}} |
| − | | | + | |blue={{#expr:{{{b|0}}}/2.55 round 0}} |
| − | + | |hex={{{hex|{{#switch:{{#expr:(({{{r|0}}})/16-0.5 round 0)mod 16}}|-1|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|0}}})mod 16}}|-1|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|0}}})/16-0.5 round 0)mod 16}}|-1|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|0}}})mod 16}}|-1|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|0}}})/16-0.5 round 0)mod 16}}|-1|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|0}}})mod 16}}|-1|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|?}} }}} | |
| − | + | |h={{#switch:{{{h}}}|-|–|/|—=—||#default={{Nts|{{{h|{{#expr:{{#ifexpr:({{{r|0}}})=({{{g|0}}})and({{{g|0}}})=({{{b|0}}})|0|{{#expr:{{#ifexpr:({{{g|0}}})>=({{{r|0}}})and({{{g|0}}})>=({{{b|0}}})|{{#ifexpr:({{{r|0}}})>({{{b|0}}})|120-60*(({{{r|0}}})-({{{b|0}}}))/(({{{g|0}}})-({{{b|0}}}))|120+60*(({{{b|0}}})-({{{r|0}}}))/(({{{g|0}}})-({{{r|0}}}))}}|{{#ifexpr:({{{b|0}}})>=({{{r|0}}})and({{{b|0}}})>=({{{g|0}}})|{{#ifexpr:({{{g|0}}})>({{{r|0}}})|240-60*(({{{g|0}}})-({{{r|0}}}))/(({{{b|0}}})-({{{r|0}}}))|240+60*(({{{r|0}}})-({{{g|0}}}))/(({{{b|0}}})-({{{g|0}}}))}}|{{#ifexpr:({{{b|0}}})>({{{g|0}}})|360-60*(({{{b|0}}})-({{{g|0}}}))/(({{{r|0}}})-({{{g|0}}}))|60*(({{{g|0}}})-({{{b|0}}}))/(({{{r|0}}})-({{{b|0}}}))}}}}}} round 1}}}} round 0}} }}}|}}}} | |
| + | |hue={{{hue|−{{#expr:360-{{#ifexpr:({{{r|0}}})=({{{g|0}}})and({{{g|0}}})=({{{b|0}}})|0|{{#expr:{{#ifexpr:({{{g|0}}})>=({{{r|0}}})and({{{g|0}}})>=({{{b|0}}})|{{#ifexpr:({{{r|0}}})>({{{b|0}}})|120-60*(({{{r|0}}})-({{{b|0}}}))/(({{{g|0}}})-({{{b|0}}}))|120+60*(({{{b|0}}})-({{{r|0}}}))/(({{{g|0}}})-({{{r|0}}}))}}|{{#ifexpr:({{{b|0}}})>=({{{r|0}}})and({{{b|0}}})>=({{{g|0}}})|{{#ifexpr:({{{g|0}}})>({{{r|0}}})|240-60*(({{{g|0}}})-({{{r|0}}}))/(({{{b|0}}})-({{{r|0}}}))|240+60*(({{{r|0}}})-({{{g|0}}}))/(({{{b|0}}})-({{{g|0}}}))}}|{{#ifexpr:({{{b|0}}})>({{{g|0}}})|360-60*(({{{b|0}}})-({{{g|0}}}))/(({{{r|0}}})-({{{g|0}}}))|60*(({{{g|0}}})-({{{b|0}}}))/(({{{r|0}}})-({{{b|0}}}))}}}}}} round 1}}}} round 0}}}}} | ||
| + | |sat={{{sat|{{#expr:100*{{#ifexpr:({{{r|0}}})=({{{g|0}}})and({{{g|0}}})=({{{b|0}}})|0|{{#expr:{{#ifexpr:({{{g|0}}})>=({{{r|0}}})and({{{g|0}}})>=({{{b|0}}})|{{#ifexpr:({{{r|0}}})>({{{b|0}}})|(({{{g|0}}})-({{{b|0}}}))/({{#ifexpr:({{{g|0}}})+({{{b|0}}})>255|510-({{{g|0}}})-({{{b|0}}})|({{{g|0}}})+({{{b|0}}})}})|(({{{g|0}}})-({{{r|0}}}))/({{#ifexpr:({{{g|0}}})+({{{r|0}}})>255|510-({{{g|0}}})-({{{r|0}}})|({{{g|0}}})+({{{r|0}}})}})}}|{{#ifexpr:({{{r|0}}})>=({{{b|0}}})and({{{r|0}}})>=({{{g|0}}})|{{#ifexpr:({{{b|0}}})>({{{g|0}}})|(({{{r|0}}})-({{{g|0}}}))/({{#ifexpr:({{{r|0}}})+({{{g|0}}})>255|510-({{{r|0}}})-({{{g|0}}})|({{{r|0}}})+({{{g|0}}})}})|(({{{r|0}}})-({{{b|0}}}))/({{#ifexpr:({{{r|0}}})+({{{b|0}}})>255|510-({{{r|0}}})-({{{b|0}}})|({{{r|0}}})+({{{b|0}}})}})}}|{{#ifexpr:({{{g|0}}})>({{{r|0}}})|(({{{b|0}}})-({{{r|0}}}))/({{#ifexpr:({{{b|0}}})+({{{r|0}}})>255|510-({{{b|0}}})-({{{r|0}}})|({{{b|0}}})+({{{r|0}}})}})|(({{{b|0}}})-({{{g|0}}}))/({{#ifexpr:({{{b|0}}})+({{{g|0}}})>255|510-({{{b|0}}})-({{{g|0}}})|({{{b|0}}})+({{{g|0}}})}})}}}}}} round 3}}}} round 0}}}}} | ||
| + | |l={{{l|{{#expr:100*{{#expr:({{#ifexpr:({{{r|0}}})>=({{{g|0}}})and({{{g|0}}})>=({{{b|0}}})or({{{b|0}}})>=({{{g|0}}})and({{{g|0}}})>=({{{r|0}}})|({{{r|0}}})+({{{b|0}}})|{{#ifexpr:({{{g|0}}})>=({{{b|0}}})and({{{b|0}}})>=({{{r|0}}})or({{{r|0}}})>=({{{b|0}}})and({{{b|0}}})>=({{{g|0}}})|({{{g|0}}})+({{{r|0}}})|({{{b|0}}})+({{{g|0}}})}}}})/510 round 3}} round 0}}}}} | ||
| + | |s={{{s|{{#expr:100*{{#ifexpr:({{{r|0}}})+({{{g|0}}})+({{{b|0}}})=0|0|{{#expr:abs({{#ifexpr:({{{r|0}}})>=({{{g|0}}})and({{{g|0}}})>=({{{b|0}}})or({{{b|0}}})>=({{{g|0}}})and({{{g|0}}})>=({{{r|0}}})|({{{r|0}}})-({{{b|0}}})|{{#ifexpr:({{{g|0}}})>=({{{b|0}}})and({{{b|0}}})>=({{{r|0}}})or({{{r|0}}})>=({{{b|0}}})and({{{b|0}}})>=({{{g|0}}})|({{{g|0}}})-({{{r|0}}})|({{{b|0}}})-({{{g|0}}})}}}})/({{#ifexpr:({{{r|0}}})>=({{{g|0}}})and({{{r|0}}})>=({{{b|0}}})|({{{r|0}}})|{{#ifexpr:({{{g|0}}})>=({{{r|0}}})and({{{g|0}}})>=({{{b|0}}})|({{{g|0}}})|({{{b|0}}})}}}}) round 3}}}} round 0}}}}} | ||
| + | |v={{{v|{{#expr:100*{{#expr:({{#ifexpr:({{{r|0}}})>=({{{g|0}}})and({{{r|0}}})>=({{{b|0}}})|({{{r|0}}})|{{#ifexpr:({{{g|0}}})>=({{{r|0}}})and({{{g|0}}})>=({{{b|0}}})|({{{g|0}}})|({{{b|0}}})}}}})/255 round 3}} round 0}}}}} | ||
| + | |alias={{{html_name|{{{alias|}}}}}} | ||
| + | |source={{{source|}}} | ||
| + | |border={{{border|#AAA}}} | ||
| + | |padding={{{padding|{{#if:{{{narrow|}}}|0|21px}}}}} | ||
| + | |width={{{width|{{#if:{{{narrow|}}}|1em|4em}}}}} | ||
| + | |id={{{link target|}}} | ||
| + | }}<noinclude> | ||
|} | |} | ||
| − | + | {{documentation}} | |
| − | + | <!-- | |
| − | + | Templates that have been subst:ituted to increase performance: | |
| − | + | * {{tl|hex3}} or trice {{tl|hex2}} | |
| + | * {{tl|RGBtoHSL.H}} | ||
| + | * {{tl|RGBtoHSL.S}} | ||
| + | * {{tl|RGBtoHSL.L}} | ||
| + | * {{tl|RGBtoHSV.S}} | ||
| + | * {{tl|RGBtoHSV.V}} | ||
| + | --> | ||
</noinclude> | </noinclude> | ||
Latest revision as of 23:30, 12 November 2020
| Name | Hex (RGB) |
Red (RGB) |
Green (RGB) |
Blue (RGB) |
Hue (HSL/HSV) |
Satur. (HSL) |
Light (HSL) |
Satur. (HSV) |
Value (HSV) |
|---|---|---|---|---|---|---|---|---|---|
| no name | #000000 | 0% | 0% | 0% | Template:Nts° | 0% | 0% | 0% | 0% |
Color table row, for use with {{Colort}}, which creates the column headings.
Usage
{{Colort/Color
|name=common name– may contain markup|alias=alternative nameor|html_name=html name|sort=sort name– an alternative name or spelling that should be used for sorting, must not contain markup|r=red decimal value– 0–255, percent values are automatically generated|g=green decimal value– 0–255, percent values are automatically generated|b=blue decimal value– 0–255, percent values are automatically generated|hex=hex triplet– can be automatically generated|h=hue degrees– HSV/HSB and HSL, can be automatically generated|s=saturation percent– HSV/HSB, can be automatically generated|v=brightness/value percent– HSV/HSB, can be automatically generated|sat=saturation percent– HSL, can be automatically generated|l=lightness percent– HSL, can be automatically generated
}}
If not provided, values for HSL, HSV and hex triplet are auto-generated from RGB parameters. That means, parameters name, r, g and b are required, the rest is optional and mostly should only be used if the automatic calculation yields rounding errors or fails for other reasons.
The hash sign # for hex triplets, percent % and degree ° symbols must not be entered as they are included automatically.
Parameters
TemplateData for Colort/Color
Table row with digital color data, usually in 11 or 12 columns.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| common name | name | the vulgar color name, may contain markup | Line | required |
| alternative name | alias html_name | usually used for synonymous names, but may be used for arbitrary content if the last column header is changed | Line | optional |
| (deprecated) | html_name | legacy variant of alias parameter, kept for backwards compatibility only | Line | deprecated |
| sort name | sort | an alternative name or spelling that should be used for sorting, must not contain markup like links | Line | optional |
| code name | code | the color name as used in computer code (e.g. special capitalization or spelling with hyphens, underscores or spaces), must not contain markup | Line | optional |
| color article | link | the Wikipedia article title explaining this color, must not contain markup | Page | optional |
| red component (RGB) | r | decimal 8bit value (0–255), percent value is generated automatically
| Number | required |
| green component (RGB) | g | decimal 8bit value (0–255), percent value is generated automatically
| Number | required |
| blue component (RGB) | b | decimal 8bit value (0–255), percent value is generated automatically
| Number | required |
| hex triplet (RGB) | hex | six hexadecimal digits, automatically preceded by a hash sign (#) as used in several computer languages, e.g. CSS
| Line | optional |
| hue (HSB/HSV, HSL) | h | in degrees (0–359), automatically succeeded by degrees sign (°)
| Number | optional |
| saturation (HSB/HSV) | s | percentage (0–100), automatically succeeded by percent sign (%), usually differs from HSL saturation
| Number | optional |
| brightness/value (HSB/HSV) | v | percentage (0–100), automatically succeeded by percent sign
| Number | optional |
| saturation (HSL) | sat | percentage (0–100), automatically succeeded by percent sign (%), usually differs from HSV/HSB saturation
| Number | optional |
| lightness/luminance (HSL) | l | percentage (0–100), automatically succeeded by percent sign (%)
| Number | optional |
| narrow layout switch | narrow | if specified this parameters changes the layout to a narrower one that covers two rows, must be specified for all neighboring rows too | Line | optional |
| extra right padding | padding | a valid CSS length value, usually set appropriately to care for sort buttons in column headers, should be specified for all neighboring rows too
| Line | optional |
| color sample column width | width | a valid CSS length value setting the width of the first column, should be specified for all neighboring rows too
| Line | optional |
| border color | border | a valid CSS color value or name for the color of cell borders, usually a light gray
| Line | optional |
| TOC anchor | link target | provides a link target, especially for links from the table of contents, should usually be specified only for the first color name starting with a certain letter in an alphabetically sorted list, to said letter, uppercase | Line | optional |
Copy and Paste
{{Colort/Color|name=|r=|g=|b=}}
{{Colort/Color|name=|alias=|sort=|r=|g=|b=}}
{{Colort/Color|name=|alias=|sort=|r=|g=|b=|hex=|h=|sat=|l=|s=|v=}}
Examples
See X11 color names, Web colors, or "what links here".
Code
The {{colort/Color}} template provides the calculation of missing values, the actual table row design is found in {{colort/1row}} (default) or {{colort/2row}} for a narrow, non-sortable variant with two rows per color. These two sub-templates should never be used directly elsewhere!
| The above documentation is transcluded from Template:Colort/Color/doc. (edit | history) Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages. Please add categories to the /doc subpage. Subpages of this template. |