Skip to main content

Colour Picker

Hex(#FFFFFF)
RGB(255, 255, 255)
RGB(100, 100, 100)
RGB(1.0, 1.0, 1.0)
HSV(360, 100, 100)
HSL(360, 100, 100)
OpenCV HSV(180, 255, 255)
Standard HSV/HSL use Hue in degrees and component percentages; OpenCV uses a scaled HSV form with H on 0-180 and S/V on 0-255.
Hold Shift while copying RGB (1.0 range) to append f suffixes (e.g. 1.0f,0.7f,0.7f).

I found that many colour pickers online only supported one format e.g. RGB out of 255, when I need different ones depending on the context. This aims to cover a few different formats.

Equations​

For RGB normalised to [0,1][0,1]:

M=max⁡(R,G,B),m=min⁡(R,G,B),Δ=M−mM = \max(R,G,B),\quad m = \min(R,G,B),\quad \Delta = M - m

HSV:

V=M,SHSV={0M=0Δ/MM≠0V = M,\qquad S_{\mathrm{HSV}} = \begin{cases} 0 & M = 0 \\ \Delta / M & M \ne 0 \end{cases}

HSL:

L=M+m2,SHSL={0Δ=0Δ1−∣2L−1∣Δ≠0L = \frac{M + m}{2},\qquad S_{\mathrm{HSL}} = \begin{cases} 0 & \Delta = 0 \\ \dfrac{\Delta}{1 - |2L - 1|} & \Delta \ne 0 \end{cases}

Hue (used by both HSV and HSL):

H={60∘ ⁣(G−BΔ mod 6)M=R60∘ ⁣(B−RΔ+2)M=G60∘ ⁣(R−GΔ+4)M=BH = \begin{cases} 60^\circ\!\left(\dfrac{G-B}{\Delta} \bmod 6\right) & M = R \\ 60^\circ\!\left(\dfrac{B-R}{\Delta} + 2\right) & M = G \\ 60^\circ\!\left(\dfrac{R-G}{\Delta} + 4\right) & M = B \end{cases}

HSV to RGB (with HH in degrees and S,V∈[0,1]S,V \in [0,1]):

C=VS,X=C(1−∣(H60∘ mod 2)−1∣),m=V−CC = VS,\qquad X = C\left(1 - \left|\left(\frac{H}{60^\circ} \bmod 2\right) - 1\right|\right),\qquad m = V - C (R′,G′,B′)={(C,X,0)0≤H<60∘(X,C,0)60∘≤H<120∘(0,C,X)120∘≤H<180∘(0,X,C)180∘≤H<240∘(X,0,C)240∘≤H<300∘(C,0,X)300∘≤H<360∘(R',G',B') = \begin{cases} (C,X,0) & 0 \le H < 60^\circ \\ (X,C,0) & 60^\circ \le H < 120^\circ \\ (0,C,X) & 120^\circ \le H < 180^\circ \\ (0,X,C) & 180^\circ \le H < 240^\circ \\ (X,0,C) & 240^\circ \le H < 300^\circ \\ (C,0,X) & 300^\circ \le H < 360^\circ \end{cases} R=R′+m,G=G′+m,B=B′+mR = R' + m,\qquad G = G' + m,\qquad B = B' + m

In this picker, the large square is HSV (S,V)(S,V), so along the top edge (V=1)(V=1), SHSVS_{\mathrm{HSV}} changes across the row while SHSLS_{\mathrm{HSL}} stays at 100%100\% except at white.