Color System

Color System Summary

Easy Graphics uses Qt’s Color System

A color is normally specified in terms of RGB (red, green, and blue) components ( using color_rgb()), but it is also possible to specify it in terms of HSV (hue, saturation, and value) (using color_hsv())and CMYK (cyan, magenta, yellow and black) components (user color_cymk()).

qcolor-rgb qcolor-hsv qcolor-cmyk

Instead of RGB, HSV or CMYK values, A color can be set by passing an RGB string (such as “#112233”), or an ARGB string (such as “#ff112233”) or a color name (such as “blue”). The color names are taken from the SVG 1.0 color names.

The color components can be retrieved individually, e.g with red(), hue() and cyan() member functions. The values of the color components can also be retrieved in one go using the getRgb(), getHsv() and getCmyk() member functions.

Predefined Colors

There are 24 predefined colors described by the Color constants.



So to set the pen’s color to red , we can:

  1. Use predefined Color const

  2. Use RGB values and color_rgb() function

  3. Use a color name

  4. Use a css web color string

  5. Use a rgb integer


Transparency (Alpha Value)

Like most modern graphic systems, Easygraphics ( and its underlying Qt System) use a alpha component to represent the transparency of a pixel on the image. When the alpha value is 255, the pixel is fully opaque; when the alpha value is 0, the pixel is fully tranparent.

All the color functions (color_rgb()/color_hsv()/color_cmyk()) has an optional parameter “alpha” to make a color with transparency. The default value of this parameter is 255, which means the color is fully opaque.

You can use to_alpha() function to make a tranparency color by string or rgb integers.

The following code set the foreground color to a red with 150 as alpha value ( about half transparent)