Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Color/doc: Difference between revisions

From Neodyland Wiki
mNo edit summary
m 18 revisions imported
 
(14 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Module rating|pre-alpha<!-- alpha • beta • release • protected • semiprotected -->}}
{{Module rating|release}}
{{high-use|615}}
This module is used primarily by {{tl|Infobox color}}, eliminating the need for external color converters and preventing mismatch between color coordinates.
This module is used primarily by {{tl|Infobox color}}, eliminating the need for external color converters and preventing mismatch between color coordinates.


Line 7: Line 8:
To convert a hexadecimal triplet to an RGB triplet as comma-separated values:
To convert a hexadecimal triplet to an RGB triplet as comma-separated values:
:<code><nowiki>{{</nowiki>#invoke:Color|''hexToRgbTriplet''<nowiki>|color}}</nowiki></code>
:<code><nowiki>{{</nowiki>#invoke:Color|''hexToRgbTriplet''<nowiki>|color}}</nowiki></code>
To convert a hexadecimal triplet to the [[CMYK color model]] without a color profile (which is a very bad idea!):
:<code><nowiki>{{</nowiki>#invoke:Color|''hexToCmyk''<nowiki>|color|precision=?|pctsign=?}}</nowiki></code>


To convert a hexadecimal triplet to [[HSL and HSV|HSL or HSV]]:
To convert a hexadecimal triplet to [[HSL and HSV|HSL or HSV]]:
Line 12: Line 16:
:<code><nowiki>{{</nowiki>#invoke:Color|''hexToHsv''<nowiki>|color|precision=?}}</nowiki></code>
:<code><nowiki>{{</nowiki>#invoke:Color|''hexToHsv''<nowiki>|color|precision=?}}</nowiki></code>


To convert a hexadecimal triplet to the perceptual [[CIELChuv|CIELChuv<sub>uv</sub>]] color space:
To convert a hexadecimal triplet to the perceptual [[CIELChuv|CIELCh<sub>uv</sub>]] color space:
:<code><nowiki>{{</nowiki>#invoke:Color|''hexToCielch''<nowiki>|color|precision=?}}</nowiki></code>
:<code><nowiki>{{</nowiki>#invoke:Color|''hexToCielch''<nowiki>|color|precision=?}}</nowiki></code>


The <code>precision</code> parameter is optional and defaults to zero.
To mix two colors in the more physically correct linear RGB space:
:<code><nowiki>{{</nowiki>#invoke:Color|''hexMix''<nowiki>|color1|color2|proportion|min=?|max=?}}</nowiki></code>
 
To convert an RGB triplet to a hex code:
:<code><nowiki>{{</nowiki>#invoke:Color|''rgbTripletToHex''<nowiki>|r|g|b}}</nowiki></code>
 
The following parameters are optional:
* <code>precision</code>: defaults to <code>0</code> (zero)
* <code>pctsign</code>: set to <code>0</code> (zero) to suppress percent signs in the generated output
* <code>proportion</code>: proportion of <code>color2</code>, defaults to 50
* <code>min</code>: minimum value of proportion range, defaults to 0
* <code>max</code>: maximum value of proportion range, defaults to 100


<includeonly>{{Sandbox other||
<includeonly>{{Sandbox other||
[[Category:Modules handling colors]]
[[Category:Modules handling colors]]
}}</includeonly>
}}</includeonly>
<noinclude>
[[Category:Module documentation pages]]
</noinclude>

Latest revision as of 16:37, 12 August 2026

This template is being used in the wrong namespace. Use {{Heavily used module}} instead! This module is used primarily by {{Infobox color}}, eliminating the need for external color converters and preventing mismatch between color coordinates.

Usage

edit

To use this module, you may use one of the above listed templates or invoke the module directly. All functions that accept hexadecimal triplets also handle the shorthand three-digit format.

To convert a hexadecimal triplet to an RGB triplet as comma-separated values:

{{#invoke:Color|hexToRgbTriplet|color}}

To convert a hexadecimal triplet to the CMYK color model without a color profile (which is a very bad idea!):

{{#invoke:Color|hexToCmyk|color|precision=?|pctsign=?}}

To convert a hexadecimal triplet to HSL or HSV:

{{#invoke:Color|hexToHsl|color|precision=?}}
{{#invoke:Color|hexToHsv|color|precision=?}}

To convert a hexadecimal triplet to the perceptual CIELChuv color space:

{{#invoke:Color|hexToCielch|color|precision=?}}

To mix two colors in the more physically correct linear RGB space:

{{#invoke:Color|hexMix|color1|color2|proportion|min=?|max=?}}

To convert an RGB triplet to a hex code:

{{#invoke:Color|rgbTripletToHex|r|g|b}}

The following parameters are optional:

  • precision: defaults to 0 (zero)
  • pctsign: set to 0 (zero) to suppress percent signs in the generated output
  • proportion: proportion of color2, defaults to 50
  • min: minimum value of proportion range, defaults to 0
  • max: maximum value of proportion range, defaults to 100
Contents
Cookies help us deliver our services. By using our services, you agree to our use of cookies.