Rich Newman

May 14, 2007

Using HSL Color (Hue, Saturation, Luminosity) to Create Better-Looking GUIs (Part 3)

Filed under: .net, c#, Color, dotnet, GUI, HSL, RGB, technology, User Interface — richnewman @ 11:17 pm

Continued from part 2

Part 1 and part 2 of this article discussed the hue, saturation, luminosity color model, and created a class, HSLColor, that allowed colors specified using this model to be used in place of the more usual System.Drawing.Color class.

Uses of Hue, Saturation, Luminosity

So why is the hue, saturation, luminosity color model useful?

Back in part 1 I showed a color scheme designed by developers for an actual business application. This contained colors that didn’t go particularly well together overall. In particular some screens seemed brighter than others, and pairs of colors used for alternate lines in the grid were inconsistent. Sometimes they were the same color at differing strengths, sometimes completely different colors.

What we actually want is a color scheme that uses differing colors (hues) that are of similar ‘strength’ across all the screens. This is easily achieved with the hue, saturation, luminosity color model. We simply choose values for saturation and luminosity and vary the hue across the various screens. This works quite well if we use white as our alternating color in the grids (so we have a colored row alternating with a white row on every grid).

White Stripes

Color scheme 2 shows this:

Color Scheme 2

This color scheme uses a saturation of 240 and luminosity of 227 for all the colored rows, with the hue varying as below. It uses white (saturation 240, luminosity 240) for the alternate rows.

The hues used in the various screens in color scheme 2 are:

Red 0
Orange 20
Yellow 40
Green 80
Cyan 120
Blue 160
Violet 180
Magenta 200
Pink 220

Colored Stripes

In fact, we can go a stage further and choose two sets of values for saturation and luminosity for alternate rows on any grid, but use the same hue for each screen. Color scheme 3 shows an example of this:

Color Scheme 2

This uses a saturation of 240 and luminosity of 227 for all the dark colored rows as above, but then uses a saturation of 240 and a luminosity of 233 for the lighter rows. The hues shown on the color scheme vary as shown in the section above.

One difficulty with using color in this way is that the color settings on individual screens vary greatly. In particular colors that look quite dark on certain screens can look almost white on others. There’s no easy way around this.

On the business application I was discussing above we have offered the user the choice of which of these color schemes to go for, as well as options for the brightness of the colors. However, we have defaulted to a color scheme close to color scheme 2.


These color schemes were all generated using the HSLColor class described in part 2. In part 4 I will post the full code for this.



  1. Your articles are a pleasure to read with high quality content. Thanks for that!

    Comment by Uwe Keim — June 21, 2007 @ 7:55 am

  2. Thank you very much!

    Comment by Anonymous — December 6, 2007 @ 10:05 pm

  3. This is great.

    Comment by Chris Lively — January 25, 2008 @ 5:36 pm

  4. I’m a big fan of HSL colors for obvious reasons.
    The following page helps for better choosing HSL colors:

    Comment by John — May 12, 2008 @ 12:40 am

  5. This article is very useful, and the HSLColor class was just what I was looking for!

    If anyone needs it, I now have an implementation of the HSLColor class in VB.NET.

    Comment by Tracy Dryden — May 21, 2012 @ 3:43 pm

  6. Thanks for the nice article. How would I calculate a color with the opposite hue using this code?

    Comment by Robert — November 13, 2012 @ 11:01 am

  7. Can somebody explain how to use this HSL class ? What controls do I need on form, what code goes where etc. ? I can’t figue out how to use this. I’m working in VB.NET.

    Comment by luka — April 23, 2017 @ 2:30 pm

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

%d bloggers like this: