Skip to content

HWB

The HWB color space is registered in Color by default

Properties

Name: hwb

White Point: D65 / 2˚

Coordinates:

Name Range
h [0, 360)
w [0, 1]
b [0, 1]

HWB 3D

HWB color space in 3D

HWB is a cylindrical-coordinate representation of points in an RGB color model, similar to HSL and HSV. It was developed by HSV's creator Alvy Ray Smith in 1996 to address some of the issues with HSV. HWB was designed to be more intuitive for humans to use and slightly faster to compute. The first coordinate, H (Hue), is the same as the Hue coordinate in HSL and HSV. W and B stand for Whiteness and Blackness respectively and range from 0-100% (or 0-1). The mental model is that the user can pick a main hue and then "mix" it with white and/or black to produce the desired color.

Learn about HWB

Channel Aliases

Channels Aliases
h hue
w whiteness
b blackness

Input/Output

Parsed input and string output formats support all valid CSS forms. In addition, we also allow the color() function format using the custom name --hwb:

hwb(h w b / a)          // HWB function
color(--hwb h w b / a)  // Color function

When manually creating a color via raw data or specifying a color space as a parameter in a function, the color space name is always used:

Color("hwb", [0, 0, 100], 1)

The string representation of the color object will always default to the color(--hwb h w b / a) form, but the default string output will be the hwb(h s l / a) form.

>>> Color("hwb", [0, 0, 0])
color(--hwb 0 0 0 / 1)
>>> Color("hwb", [38.824, 0, 0]).to_string()
'hwb(38.824 0% 0%)'
>>> Color("hwb", [60, 0, 0]).to_string(percent=False)
'hwb(60 0 0)'
>>> Color("hwb", [120, 0, 0]).to_string(color=True)
'color(--hwb 120 0 0)'

Registering

from coloraide import Color as Base
from coloraide.spaces.hwb import HWB

class Color(Base): ...

Color.register(HWB())