Python Glossary Русский

all Python 3colorsysfunction

colorsys.yiq_to_rgb()

YIQ

Converts a colour from YIQ back to RGB; the components of the result are clamped to the range 0 to 1.

Syntax

r, g, b = colorsys.yiq_to_rgb(y, i, q)

Not every YIQ triple is a real colour: when out of range the function silently clamps channels to 0 or 1, so a round trip preserves the colour only for values that came from rgb_to_yiq. It is the only function in the module that does this — the others do not check bounds at all.

Examples

import colorsys
back = colorsys.yiq_to_rgb(*colorsys.rgb_to_yiq(0.2, 0.4, 0.6))
print([round(c, 3) for c in back])  # → [0.2, 0.4, 0.6]
print(colorsys.yiq_to_rgb(0.5, 0.9, 0))  # → (1.0, 0.2526911183309195, 0.0) — обрезано

See also

Open in the full glossarydocs.python.orgReport an inaccuracy