Skip to content
Jim Lee edited this page Oct 7, 2019 · 23 revisions

colorObj

Abstract:

We're human, we love colors. All sorts of hardware deal with color. Wouldn't it be nice to have a common object that can contain and manipulate colors? Take a color from one piece of hardware and pass it to another? Take a starting point of a color and blend other colors into it to create new colors? This is what colorObj is all about. Describing and manipulating colors to use with different hardware.

Constructors.

colorObj(RGBpack* buff) If you look at the memory required to hold a color object, it typically runs at about 8 bytes. This is fine until you want a bunch of them, like with a bitmap. Suddenly you really want this information packed as tightly as possible. RGBpack packs this down to 3 bytes per color (Or pixel). Less than half the memory footprint, with no loss of information. This constructor is for creating a color object from a RGBpack color.

colorObj(byte inRed, byte inGreen, byte inBlue)
Your standard "build a color from primary red green and blue values". The primary values are 0..255 or one byte each.

//colorObj(colorObj* inColor)
This one I was never able to get to work. Its a copy constructor taking a pointer to a colorObj and using that to create a new instance of itself. The problem was that the compiler kept getting this mixed up with the next constructor that takes a word as input.

colorObj(word color16)
color16 is a special way to describe a color in 16 bits (2 bytes). You do loose some color information with this compression. On the other hand, its used by a large variety of displays. So its very important to have in our bag of tricks. This is why it was kept instead of the copy constructor above.

colorObj(void) This is the "I don't care what color, just allocate some room" constructor. Very handy for grabbing a "blank" color to use as a receptacle for building a new color.

Starting points.

` // Red,Grn,blu #define LC_BLACK 0, 0, 0 #define LC_CHARCOAL 50, 50, 50 // NEED TO BE ADDED TO SWITCH STATEMENT!! #define LC_DARK_GREY 140,140,140 #define LC_GREY 185,185,185 // NEED TO BE ADDED TO SWITCH STATEMENT!! #define LC_LIGHT_GREY 250,250,250 #define LC_WHITE 255,255,255

#define LC_RED 255, 0, 0 #define LC_PINK 255,130,208

#define LC_GREEN 0,255, 0 #define LC_DARK_GREEN 0, 30, 0 #define LC_OLIVE 30, 30, 1

#define LC_BLUE 0, 0,255 #define LC_LIGHT_BLUE 164,205,255 #define LC_NAVY 0, 0, 30

#define LC_PURPLE 140, 0,255 #define LC_LAVENDER 218,151,255 #define LC_ORANGE 255,128, 0

#define LC_CYAN 0,255,255 #define LC_MAGENTA 255, 0,255 #define LC_YELLOW 255,255, 0 `

Yes! I used #define. Hahahaha!!! They said I was crazy. It's THEM that are crazy!

Anyway..

These are a set of handy starting points for building colors. They are #defines in a way that they pplug directly into the standard primary constructor.

For example: colorObj aColor(LC_LIGHT_BLUE);

And now aColor is holding a light blue color.

Other methods..

Clone this wiki locally