Simple Formulas for Calculating Tints and Shades

by Marshall Farrier|2/12/10

Tints and shades provide additional color options for a GUI or website without clashing with its underlying color scheme. It is not entirely clear, however, just how in general to derive tints mathematically from a base color. Here, I'm going to present 2 simple formulas for deriving shades and for deriving tints. I'll then use the color scheme of this website to show the color range defined by each formula. While these formulas leave out many of the complications associated with saturation issues, I think they are still quite usable.

Shades

For darkening or shading a color, the basic formula seems pretty obvious: If x, y and z are the red, green and blue arguments for the original color (let's say '#xyz' representing each number as a 2-digit hex value), and you want a shade representing amount s0 (<=1) of '#xyz', then the shade should be '#abc' where a = s0 * x, b = s0 * y, and c = s0 * z, again using 2-digit hexadecimal representations when converting to strings.

Melon (#191106 through #ffb13d):
Green (#111906 through #b1ff3d):
Brown/beige (#191610 through #ffe2a3):
Blue (#101619 through #a3e2ff):

Note first that in each case the brightest color uses 0xff (decimal 255) for one of its rgb components, and 0xff of course represents the maximum allowable intensity. Once we reach that number, we can no longer increase each component proportionally within the numeric framework of the rgb encoding.

Secondly, this method produces shades equivalent to those an artist would create by adding black to a base color. With a specific color scheme, one certainly might also want to weight the shading toward one or another part of the spectrum. For example, if you want your color to have blue shades, you might want to reduce the red and green components disproportionately to the blue rather than reducing all 3 components in the same proportion. Given the subjectively determined weighting for the shading, one could certainly also look for appropriate transformations of our simple linear formula, but I'm not going to examine such issues here.

Tints

While you can't make a color brighter when one of its components is 0xff (255), you can make it lighter by adding white. The easiest way to formulate an equation in this case is to take the tint factor t0 to represent the percentage of the original color to mix with white (#fff). Again we want t0 <= 1, and a tint #abc of a color #xyz can now be derived from the formulas:

a = (t0 * x) + (255 * (1 - t0))
b = (t0 * y) + (255 * (1 - t0))
c = (t0 * z) + (255 * (1 - t0))

So, let's see how the tints for the same colors look when calculated using this formula.

Melon (#ffb13d through #fff7eb):
Green (#b1ff3d through #f7ffeb):
Brown/beige (#ffe2a3 through #fffcf5):
Blue (#a3e2ff through #f5fcff):

An additional observation that's only slightly off-topic: In my favorite color schemes from COLOURlovers, I've noticed that (to my eye) harmonious colors often seem to result from transposing 2 of the 3 rgb components of one color. So, I wonder whether the eye may perceive these mathematical relationships between colors much as the ear perceives Pythagorean harmonies. For example, looking for a green to harmonize with the melon color I liked (#ffb13d), I transposed the red and green components to arrive at the color #b1ff3d. This transposition technique doesn't provide any kind of foolproof formula for finding appealing color schemes, but it does seem to work frequently enough to be worth a try.

Finally, here's an Excel ® workbook with the necessary formulas for calculating tints and shades and with functions for translating decimal into hexadecimal notation: gui_color.zip

articles

This site is currently being re-organized. As a result, several of the navigation choices above may not yet be active.