Color Chooser

Posted in: Portfolio by preitz on

For a project I did recently, I had to create a color chooser window from scratch. Making this was a lot of fun, so I decided to rebuild it and put it here in my portfolio.

Sorry, either Adobe flash is not installed or you do not have it enabled

The main workhorse behind this project is the ColorModel class. This is a model object with seven properties: color(hex), red, green, blue, hue, saturation, and brightness. What surprised me when I fist started working on this project was the fact that this class did not exist. Sure there were a couple of classes here and there that would do one conversion. Either from hex to RGB, or from RGB to HSB. But there didn’t seem to be a single color class that handled all of the properties commonly used when dealing with color.

So I had to write this class. One important thing I did with this class though; I made it lazy. There are some heavy calculations when converting from RGB to HSB (and vice versa), so the ColorModel class will not do these calculations until it has to. So if, for example, you change the red value several times, then change the green value, it won’t calculate the hue, saturation, or brightness of the color. Only when you decide to set or get one of those values will they be calculated.

For the version shown above, another thing I wanted to do (just for fun) is build it entirely in AS3. This was mostly for the challenge of doing it (and to show off). But also so I could easily provide the complete source code: ColorChooser Source

  • No Comments Yet