Jump to content

Module:Color/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m Looks stable, so beta
m Added color mixing
Line 17: Line 17:
To convert a hexadecimal triplet to the perceptual [[CIELChuv|CIELCh<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>

To mix two colors:
:<code><nowiki>{{</nowiki>#invoke:Color|''hexMix''<nowiki>|color1|color2|proportion}}</nowiki></code>


The following parameters are optional:
The following parameters are optional:
* <code>precision</code>: defaults to zero
* <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>pctsign</code>: set to <code>0</code> (zero) to suppress percent signs in the generated output
* <code>proportion</code>: percentage of <code>color2</code>, <code>0</code> (zero) outputs <code>color1</code>, defaults to 50


<includeonly>{{Sandbox other||
<includeonly>{{Sandbox other||

Revision as of 13:45, 17 January 2022

This module is used primarily by {{Infobox color}}, eliminating the need for external color converters and preventing mismatch between color coordinates.

Usage

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:

{{#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:

{{#invoke:Color|hexMix|color1|color2|proportion}}

The following parameters are optional:

  • precision: defaults to 0 (zero)
  • pctsign: set to 0 (zero) to suppress percent signs in the generated output
  • proportion: percentage of color2, 0 (zero) outputs color1, defaults to 50