Misplaced Pages

Template:Infobox color: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Browse history interactively← Previous editContent deleted Content addedVisualWikitext
Revision as of 02:33, 5 January 2008 view sourcePaleAqua (talk | contribs)Extended confirmed users, Pending changes reviewers5,182 editsm Note that bgcolor is optional.← Previous edit Latest revision as of 22:42, 4 August 2024 view source LaundryPizza03 (talk | contribs)Extended confirmed users51,864 edits Ensure correct color display in dark mode 
(106 intermediate revisions by 33 users not shown)
Line 1: Line 1:
{{infobox
<!-- with a width of 260px, each entry for the color blue can fit on a single line
| above = {{{title|<includeonly>{{PAGENAME}}</includeonly>}}}
:Not at all font sizes. It can never be assumed that text will have a fixed pixel size. I changed it to 21em. This makes all entries for the color blue fit on a single line, at all tested font sizes. ]
| subbox = {{{subbox|}}}
-->{| class="toccolours" style="float:right; width:21em; clear:right; margin: 0em 0em 1em 1em;"
| subheader = {{#if:{{{hex|}}}|&nbsp;}}
|-
! colspan="3" style="text-align: center; background-color:#{{{bgcolor|{{{hex}}}}}}; color:{{{textcolor|inherit}}};" | {{{title}}} | subheaderstyle = line-height:12px; background-color:#{{{hex}}}!important; border: 0.1px solid #000000
| subheaderclass = mw-no-invert
|-
| image = {{#invoke:InfoboxImage|InfoboxImage|image={{{image|}}}|size={{{image_size|{{{photo-size|}}}}}}|sizedefault=frameless|alt={{{alt|}}}}}
{{#ifeq:{{{pic|1}}}|{{{pic|2}}}|! style="text-align:center;" colspan="3" {{!}} ]}}
| caption = {{{caption|}}}
|-
| header2 = {{#if:{{{frequency|}}}|]}}
{{#ifeq:{{{wavelength|1}}}{{{frequency|1}}}|{{{wavelength|2}}}{{{frequency|2}}}|
| label3 = ]
{{!}} colspan="3" style="height:25px; text-align: center;" {{!}} &mdash; ] &mdash;}}
| data3 = {{#if:{{{wavelength|}}}|{{{wavelength}}} ]}}
|-
| label4 = ]
{{#ifeq:{{{wavelength|1}}}|{{{wavelength|2}}}|! style="text-align:left;" colspan="2" {{!}} ]
{{!}} {{{wavelength}}} ]}} | data4 = {{#if:{{{frequency|}}}|{{{frequency}}} ]}}
| header5 = {{#if:{{{symbolism|}}}|Common connotations}}
|-
| data6 = {{{symbolism||yy}}}
{{#ifeq:{{{frequency|1}}}|{{{frequency|2}}}|! style="text-align:left;" colspan="2" {{!}} ]
| header8 = <includeonly><span style="position: relative; float: right; font-size: 70%">]</span> &nbsp; &nbsp; Colo{{#ifeq:{{lc:{{{spelling}}}}}|colour|u}}r coordinates</includeonly>
{{!}} {{{frequency}}} ]}}
| label9 = ]
|-
{{#ifeq:{{{symbolism|1}}}|{{{symbolism|2}}}| | data9 = {{#if:{{{hex|}}}|&#35;{{{hex}}}{{{hexref|}}}}}
| label10 = {{nowrap|]<sup>'''B'''</sup> (], ], ])}}
{{!}} colspan="3" style="height:25px; text-align: center;" {{!}} &mdash; Commonly represents &mdash;
| data10 = {{#if:{{{hex|}}}|{{nowrap|({{#invoke:Color|hexToRgbTriplet|{{{hex}}}}})}}}}
{{!}}-
| label11 = {{nowrap|]<sup>'''H'''</sup> (], ], ], ])}}
{{!}} colspan="3" style="text-align: left;" {{!}} {{{symbolism}}}
| data11 = {{#if:{{{c|}}}|{{#if:{{{cmyk|}}}|{{nowrap|({{{c}}}, {{{m}}}, {{{y}}}, {{{k}}}){{{cmykref|]}}}}}}}|]}}|{{#if:{{{cmyk|}}}|{{error|CMYK requested, but no value given]}}}}
}}
| label12 = {{nowrap|] (], ], ])}}
|-
| data12 = {{#if:{{{hex|}}}|{{nowrap|({{#invoke:Color|hexToHsv|{{{hex}}}}})}}}}
| colspan="3" style="height:25px; text-align: center;" | <span style="position:relative; float:right; font-size:70%;"><imagemap>Image:Information-silk.png|About these coordinates
| label14 = {{nowrap|] (], ], ])}}
rect 0 0 50 50 ]
| data14 = {{#if:{{{hex|}}}|{{nowrap|({{#invoke:Color|hexToCielch|{{{hex}}}}})}}}}
desc none</imagemap></span>&mdash; {{ #ifeq:{{lc:{{{spelling}}}}}|colour|Colour|Color}} coordinates &mdash;
| label15 = Source
|-
| data15 = <includeonly>{{#if:{{{source|}}}|{{{source}}}|<sup><nowiki>]<nowiki>]</nowiki></sup>{{main other|]}}}}</includeonly>
{{#ifeq:{{{r|1}}}|{{{r|2}}}|! style="text-align:left;" colspan="2" {{!}} ]
| label17 = ]
{{!}} #{{{hex}}}}}
| data17 = {{{isccname|}}}
|-
| data18 = {{#if:{{{hex|}}}|'''B''': Normalized to <nowiki> (byte)<br>}}{{#if:{{{cmyk|}}}|{{#if:{{{hex|}}}{{{c|}}}|'''H''': Normalized to <nowiki> (hundred)}}}}
{{#ifeq:{{{r|1}}}|{{{r|2}}}|! style="text-align:left;" {{!}} {{#ifeq:{{{sRGB|1}}}|{{{sRGB|2}}}|]|{{{rgbspace|]}}}}}<sup>'''B'''</sup>
| data19 = {{{caveat|}}}
{{!}} (], ], ])
{{!}} ({{{r}}}, {{{g}}}, {{{b}}})}} | header20 = {{#if:{{{variations|}}}|{{{variationstitle|Some shades of {{{title}}}|}}}}}
| label21 = {{{variation1|}}}
|-
| data21 = {{#if:{{{variation1|}}}|<span style="background-color:{{{variation1color|{{{variation1}}}}}}; border:1px solid {{{variation1color|{{{variation1}}}}}};display:block" class="mw-no-invert">&nbsp;</span>}}
{{#ifeq:{{{cmyk|1}}}|{{{cmyk|2}}}|! style="text-align:left;" {{!}} ]<sup>'''H'''</sup>
| label22 = {{{variation2|}}}
{{!}} (], ], ], ])
| data22 = {{#if:{{{variation2|}}}|<span style="background-color:{{{variation2color|{{{variation2}}}}}}; border:1px solid {{{variation2color|{{{variation2}}}}}};display:block" class="mw-no-invert">&nbsp;</span>}}
{{!}} ({{{c}}}, {{{m}}}, {{{y}}}, {{{k}}})}}
| label23 = {{{variation3|}}}
|-
| data23 = {{#if:{{{variation3|}}}|<span style="background-color:{{{variation3color|{{{variation3}}}}}}; border:1px solid {{{variation3color|{{{variation3}}}}}};display:block" class="mw-no-invert">&nbsp;</span>}}
{{#ifeq:{{{h|1}}}|{{{h|2}}}|! style="text-align:left;" {{!}} ]
| label24 = {{{variation4|}}}
{{!}} (], ], ])
| data24 = {{#if:{{{variation4|}}}|<span style="background-color:{{{variation4color|{{{variation4}}}}}}; border:1px solid {{{variation4color|{{{variation4}}}}}};display:block" class="mw-no-invert">&nbsp;</span>}}
{{!}} ({{{h}}}&deg;, {{{s}}}%, {{{v}}}%)}}
| label25 = {{{variation5|}}}
|-
| data25 = {{#if:{{{variation5|}}}|<span style="background-color:{{{variation5color|{{{variation5}}}}}}; border:1px solid {{{variation5color|{{{variation5}}}}}};display:block" class="mw-no-invert">&nbsp;</span>}}
! style="text-align:left;" colspan="2" | '''Source'''
| label26 = {{{variation6|}}}
| {{{source|<sup><nowiki>]<nowiki>]</nowiki></sup><includeonly>]</includeonly>}}}
| data26 = {{#if:{{{variation6|}}}|<span style="background-color:{{{variation6color|{{{variation6}}}}}}; border:1px solid {{{variation6color|{{{variation6}}}}}};display:block" class="mw-no-invert">&nbsp;</span>}}
<!--{{#ifeq:{{{source|1}}}|{{{source|2}}}|! style="text-align:left;" colspan="2" {{!}} '''Source'''
| label27 = {{{variation7|}}}
{{!}} {{{source}}}}}-->
| data27 = {{#if:{{{variation7|}}}|<span style="background-color:{{{variation7color|{{{variation7}}}}}}; border:1px solid {{{variation7color|{{{variation7}}}}}};display:block" class="mw-no-invert">&nbsp;</span>}}
|-
| label28 = {{{variation8|}}}
{{#ifeq:{{{colorspace|1}}}|{{{colorspace|2}}}|! style="text-align:left;" colspan="2" {{!}} ]
| data28 = {{#if:{{{variation8|}}}|<span style="background-color:{{{variation8color|{{{variation8}}}}}}; border:1px solid {{{variation8color|{{{variation8}}}}}};display:block" class="mw-no-invert">&nbsp;</span>}}
{{!}} {{{colorspace}}}}}
}}{{#if:{{{cmyk|}}}{{{c|}}}{{{m|}}}{{{y|}}}{{{k|}}}|{{Main other|]}}}}<noinclude>{{documentation}}<!-- PLEASE ADD THIS TEMPLATE'S CATEGORIES TO THE /doc SUBPAGE, THANKS --></noinclude>
|-
| colspan="3" style="text-align: center; font-size:smaller;" | {{#ifeq:{{{r|1}}}|{{{r|2}}}|'''B''': Normalized to <nowiki> (byte)<br>}}{{#ifeq:{{{cmyk|1}}}|{{{cmyk|2}}}|'''H''': Normalized to <nowiki> (hundred)<br>}}{{{caveat|}}}
|}<noinclude>
==Note==
For articles standardised to british spelling, add the parameter <code>spelling=Colour</code>. The word "colour" is case-insensitive.

Note that CMYK values are not included by default as there is no single way to obtain a CMYK quartet from an RGB triplet. Variations in paper and ink processes account for the various combinations of non-invertible matrices and look-up tables used in converting from RGB to CMYK. If you wish to obtain CMYK values for these colors, you will get appropriate conversion values from your graphics application when you define the type of ink and paper you will be printing on.
see ]

==Parameters==

The following template parameters are supported.

{| class="wikitable"
! colspan="2" style="text-align: center;" | ] Parameters (optional)
|-
! wavelength
| The ] interval in ].
|-
! frequency
| The ] in ].
|-
! colspan="2" style="text-align: center;" | Symbolism (optional)
|-
! symbolism
| What the color commonly represents. Multiple lines may be included using <nowiki><br></nowiki>
|-
! colspan="2" style="text-align: center;" | RGB Parameters (optional)
|-
! r
| The red coordinate in the RGB space. Enables the display of RGB coordinates.
|-
! g
| The green coordinate in the RGB space.
|-
! b
| The blue coordinate in the RGB space.
|-
! hex
| This parameter is also shown when RGB is specified.
|-
! rgbspace
| (Optional) Specifies the RGB space used. Replaces the default "]".
|-
! sRGB
| (Optional) Specifies that the RGB space is sRGB. Overrides rgbspace if used.
|-
! colspan="2" style="text-align: center;" | CMYK Parameters (optional)
|-
! cmyk
| Enables the display of CMYK coordinates.
|-
! c
| Cyanic CMYK color space coordinate
|-
! m
| Magenta CMYK color space coordinate
|-
! y
| Yellow CMYK color space coordinate
|-
! k
| Black CMYK color space coordinate
|-
! colspan="2" style="text-align: center;" | HSV Parameters (optional)
|-
! h
| Hue HSV color space coordinate. Enables the display of HSV coordinates.
|-
! s
| Saturation HSV color space coordinate
|-
! v
| Value HSV color space coordinate
|-
! colspan="2" style="text-align: center;" | Other Parameters
|-
! bgcolor
| (Optional) Color in hex format used for background behind the name of the color. Defaults to value specified by the hex parameter.
|-
! caveat
| (Optional) Additional text to display at the bottom of the infobox.
|-
! colorspace
| (Optional) Colorspace of this color.
|-
! hex
| Color in hex format, also used as default for bgcolor unless present.
|-
! pic
| (Optional) Name of an image to display. Do not use wikicode: use the format <code>pic=Image:Example.jpg</code>
|-
! source
| Source for these color coordinates. See ].
|-
! spelling
| (Optional) For articles standardised to the british spelling this can be set to "Colour". The word "colour" is case-insensitive.
|-
! textcolor
| (Optional) Colour in which to show the name of the colour. Should be set to white if "hex" is a dark colour, or else not set.
|-
! title
| Name of the color
|}

]
]

]
]
]
]
]
]
]
]
]
]
</noinclude>

Latest revision as of 22:42, 4 August 2024

Template documentation[view] [edit] [history] [purge]
This template uses Lua:
Sample color
 
Some altCIE colorspace
Spectral coordinates
Wavelengthnum - num nm
Frequencynum - num THz
Common connotations
Some symbols
About these coordinates     Color coordinates
Hex triplet#0080FF
sRGB (r, g, b)(0, 128, 255)
CMYK (c, m, y, k)(C, M, Y, K)
HSV (h, s, v)(210°, 100%, 100%)
CIELChuv (L, C, h)(55, 117, 255°)
SourceSample color
ISCC–NBS descriptorSome iscc name
B: Normalized to (byte)
H: Normalized to (hundred)
Some caveat
Some shades of Sample color
Darker sample 
Lighter sample 

The sRGB triplet, HSV, CIELchuv and (if enabled) CMYK coordinates are automatically calculated from the hex parameter, so they generally do not need to be specified. CMYK is hidden by default because it doesn't take color profiles into account.

Blank template

Minimal usage:

{{Infobox color
|title  = 
|hex    =
|source =
}}

Full usage:

{{Infobox color
|title      = 
|hex        =
|hexref     =
|source     =
|bgcolor    =
|image      =  
|image_size =
|alt        =
|caption    =
|frequency  =
|wavelength =
|symbolism  =
|spelling   =
|cmyk       = <!-- Set to 1 to display -->
|c=|m=|y=|k=  <!-- Give CMYK only when you know what you are doing -- see notes. -->
|cmykref    =
|colorspace =
|isccname   =
|caveat     =
|variations = 
|variation1 =|variation1color=
|variation2 =|variation2color=
|variation3 =|variation3color=
|variation4 =|variation4color=
|variation5 =|variation5color=
|variation6 =|variation6color=
|variation7 =|variation7color=
|variation8 =|variation8color=
}}

Parameters

The following template parameters are supported:

Recommended parameters
title Name of the color
hex sRGB hex triplet.
source Source for the main color coordinates, usually an RGB triplet or an hex triplet, in sRGB space. See Misplaced Pages:WikiProject Color/Sources for Color Coordinates.
Spectral color parameters (optional)
wavelength The wavelength interval in nm.
frequency The frequency in THz.
Variation samples (optional)
variations If set include some samples of variations.
variationstitle Used for the title of the variations section, otherwise "Some variations of title" is used.
variationN Name of the Nth variation, where N is between 1 and 8.
variationNcolor Color used for variationN, defaults to the web color of the same name.
CMYK parameters (optional)
cmyk Enable display of CMYK coordinates. The coordinates are otherwise hidden (see Category:Color articles with suppressed CMYK data).
c Cyanic CMYK color space coordinate
m Magenta CMYK color space coordinate
y Yellow CMYK color space coordinate
k Black CMYK color space coordinate
cmykref The reference for CMYK coordinates, if different from the main source.
Other parameters
bgcolor (Optional) Color in hex format used for background behind the name of the color. Defaults to value specified by the hex parameter.
caption (Optional) Appears under image, if specified.
caveat (Optional) Additional text to display at the bottom of the infobox.
colorspace (Optional) Colorspace of this color.
image (Optional) Name of an image to display. Do not use wikicode: use the format image=Image:Example.jpg
isccname (Optional) Display ISCC–NBS System of Color Designation color category
spelling (Optional) For articles standardised to the British spelling this can be set to "Colour". The word "colour" is case-insensitive.
symbolism What the color commonly represents. Multiple lines may be included using <br>

Notes

Color/Colour spelling

For articles standardised to British spelling, add the parameter spelling=Colour. The word "colour" is case-insensitive.

CMYK values

There is no functionality for converting RGB to CMYK because there is no single CMYK color space. Variations in paper and ink processes account for the various combinations of non-invertible matrices and look-up tables used in converting from RGB to CMYK. If you wish to obtain CMYK values for these colors, you will get appropriate conversion values from your graphics application when you define the type of ink and paper you will be printing on.

A CMYK value is meaningful only if you can specify what ink–paper–process standard it is supposed to be used with. If your color article does not specifically concern a quirk in the CMYK process (such as rich black), it's best to leave it unspecified since it does not add additional information.

Because the CMYK data quality is generally awful, the infobox currently adds an additional barrier to its use, requiring a |cmyk=1 to be passed. Articles without this parameter but still providing a CMYK value are sorted into Category:Color articles with suppressed CMYK data. An article should provide a CMYK coordinate with |cmyk=1 only when the source provides these coordinates.

See also

Simple colorbox templates to display a sample color:

Color box templates
Template Description Example
{{Color box}} Color box size with black borders and text color. Standard size.   or  ORANGE 
{{Color box striped}} Striped color box. Standard size.     
{{RouteBox}} Borderless color box with text color and wikilinks.  ORANGE 
{{Colorbull}} Colored bullet with wikilinks.
{{Legend inline}} Color box size with black borders. Standard size.   
{{Color sample}} Color box size with black borders. Smaller size.
{{Swatch inline}} orange
{{Background color}} orange
{{Rail color box}} A version with more display options. Part of Module:Adjacent stations , Orange
{{Diagonal split color box}} Color box split diagonally. Standard size.       
Color classifications
Color systems,
standards and palettes
Color names (alphabetic)
Variations of base colors
Shades of red
Shades of yellow
Shades of green
Shades of cyan
Shades of blue
Shades of magenta
Shades of orange
Shades of chartreuse
Shades of spring green
Shades of azure
Shades of violet
Shades of rose
Shades of brown
Shades of purple
Shades of pink
Shades of white
Shades of gray
Shades of black
The above documentation is transcluded from Template:Infobox color/doc. (edit | history)
Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.
Add categories to the /doc subpage. Subpages of this template. Categories: