How Saekpan works
How colors become numbers, and how contrast and color difference are calculated. Formulas and a worked example included.
HEX, RGB and HSL: what is the difference?
RGB writes red, green and blue light as values from 0 to 255. HEX is the same three values in base 16. Red is 255, 0, 0 in RGB and ff0000 in HEX.
HSL writes a color as hue, saturation and lightness. Hue is an angle on the color wheel from 0 to 360. Saturation and lightness are percentages. Red is hue 0, saturation 100%, lightness 50%. They are different scales for the same color, so values convert both ways.
The conversion follows the algorithm in CSS Color Module Level 4.
How is the contrast ratio calculated?
WCAG 2.1 starts with the relative luminance of each color. Scale each channel to 0 to 1. If it is 0.04045 or below, divide by 12.92. Otherwise raise (value + 0.055) / 1.055 to the power 2.4. Then L = 0.2126 R + 0.7152 G + 0.0722 B.
The ratio is (lighter L + 0.05) / (darker L + 0.05). Black on white is 21 and identical colors give 1. For example, #767676 on white has a luminance of about 0.181, so the ratio is about 4.54.
There are three limits. Normal text: AA 4.5, AAA 7. Large text (18pt or bigger, or 14pt bold): AA 3, AAA 4.5. Graphics such as button borders and icons: 3.
Why is CMYK only an approximation?
Screens add light to make color, while ink in print takes light away. The two cover different ranges, so some colors have no exact match.
This tool sets K = 1 - max(R, G, B) first, then finds C, M and Y as ratios. Red comes out as C 0, M 100, Y 100, K 0. It uses no ICC profile, which is what carries paper and ink behavior, so real print can differ.
What is color difference (ΔE)?
ΔE puts a number on how different two colors look. First an sRGB color goes through XYZ into the Lab color space. Lab describes a color as L (lightness), a (green to red) and b (blue to yellow).
CIE76 is the straight distance between two points in Lab. It is simple but drifts from what the eye sees for saturated colors. CIEDE2000 adds corrections for lightness, chroma and hue to reduce that. A common rule of thumb says under 1 is almost the same and around 2 needs a close look.
How are complementary and analogous colors picked?
On the HSL wheel, the complement is the hue turned 180 degrees. Analogous colors sit 30 degrees to either side, and a triadic set turns 120 degrees each time. Saturation and lightness stay the same.
The complement can differ from the RYB wheel taught in art class. This tool follows the RGB wheel used on screens.
When this may not fit
The ratio only looks at the numbers of two colors. It cannot account for font weight, background images, screen brightness or color vision differences. It does not replace an accessibility review.
CMYK values are a simple calculation. Results vary by printer and paper, so check a proof before printing. Your colors are never sent to a server or stored.