How to Define Colors in your Applications

Microchip Graphics Library

Microchip Graphics Library
How to Define Colors in your Applications

To override or define a new set of colors follow this steps:

  1. Create a new color header file. The color values and data types will depend on the GFX_COLOR type used. This data type is defined by the COLOR_DEPTH macro. See COLOR_DEPTH for details.
  2. In the application code, include the created color header file ahead of the #include "Graphics/Graphics.h". When Graphics.h includes the gfxcolors.h it will ignore color macros that has been defined already in the new color header file.
In the GOL Palette Demo, there is an example on how it is done. In that project there is a file in the application (or project directory) named PaletteColorDefines.h. This file contains all the color definition used in the demo. The main header file of the demo (Main.h) includes the PaletteColorDefines.h file ahead of the Graphics Library header files. Since the PaletteColorDefines.h declared the color values, the macros redefined in gfxcolors.h will be ignored. How is this done? If you look at the gfxcolors.h file you will notice that all colors defined have a check (for example BLACK): 

#ifndef BLACK 

#define BLACK

#endif 

So if BLACK is defined previously, the definition in gfxcolors.h will not take effect.

Links
Microchip Graphics Library Version 3.06.02 - October 15, 2012
Copyright © 2012 Microchip Technology, Inc.  All rights reserved