|
![]() |
How the tool calculations are made
RGB variationsThe RGB variations are achieved by adding or subtracting a percentage amount (of 255) of red, green and blue combinations to the current colour. Additive variations tend to produce lighter colours and subtractive variations darker colours.
Variations of multiples of 20% (20%, 40%, 60%, 80%) of a "browser-safe" colour will always produce other safe colours. This is because RGB colour is specified on a scale from 0 to 255; when the scale is divided equally into 6 parts (as happens in the "safe" 216 palette), each part is 51 units (20% of 255). Thus adding any multiple of 51 to a colour in the 216 palette will result in a colour in the same palette. Nearest safeThe "nearest safe" colour is calculated by finding the nearest number to 0, 51, 102, 153, 204 and 255 of each component of RGB colour.
Inverse
The inverse colour is calculated by subtracting each component of RGB colour from 255. Note that the inverse of a "safe" colour is always another safe colour (255 is a multiple of 51 - subtracting any multiple of 51 from 255 will result in another multiple of 51). |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
HSL variationsThe HSL variations
are calculated by
HSL variations involve changing only one of hue, saturation and lightness. The other two values remain the same.
Since the hue scale is a continuous circle, additions to hue resulting in a hue greater than 360° continue from 0° - that is, 360 is subtracted from the hue value (e.g., 350° + 20; = 370 then 370 - 360 = 10°). Similarly, a subtraction from hue resulting in a negative number is similarly adjusted by adding 360. Greys have hue Strictly speaking, black, white and greys have undefined hue. For
the purposes of calculations in this resource, we've adopted
the convention of setting hue to 0° for all greys. Black is
H: 0° S: 0% L: 0% whilst white is H: 0°
S: 0% L: 100% However, Hue 0° is red and so colours of
hue 0° with values of greater than 0% for saturation and lightness
appear red. The effects of roundingWhen making HSL variations, the resulting HSL colour value may be 1°
or 1% out because of the rounding required when converting HSL values back
to RGB hex. For example, if you add a percentage lightness to a colour
and then remove that same amount, you may not return to the exact colour
you started with. Snap to 51If a calculated variation of red, blue or green results in a number which is one out from 0, 51, 102, 153, 204 or 255, it will be adjusted to that number. For example, if a calculation results in the colour value 50,103,203 it will be adjusted to 51,102,204. To explain, the choice of percentage variations result in decimal increments
which may not be whole numbers (since they're a percentage of 255).
Because RGB colour is stated in whole numbers, calculated variations are rounded to the nearest whole number. This rounding means that a variation of 20% (=51), say, will not be equivalent to two 10% variations (=25.5); rounding up gives 26+26=52 whilst rounding down gives 25+25=50, both 1 out from the target 51. Therefore, snapping calculated numbers that are one point away from a multiple of 51 means that repeated transformations in the same direction (e.g., +10% green then +10% green) will result in a safe colour when starting from a safe colour. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||