GRASS Programmer's Manual  6.4.2(2012)
cairodriver/Color.c
Go to the documentation of this file.
00001 #include "cairodriver.h"
00002 
00003 /* "cached" color (to avoid more color change calls than necessary) */
00004 /* TODO: find a proper solution for initialization */
00005 int previous_color = 0x7FFFFFFF;
00006 
00007 void Cairo_color(int color)
00008 {
00009     G_debug(3, "Cairo_color: %d", color);
00010 
00011     if (color != previous_color) {
00012         int r = (color >> 16) & 0xFF;
00013         int g = (color >> 8) & 0xFF;
00014         int b = (color >> 0) & 0xFF;
00015 
00016         cairo_set_source_rgba(cairo, CAIROCOLOR(r), CAIROCOLOR(g),
00017                               CAIROCOLOR(b), 1.0);
00018         previous_color = color;
00019 
00020         G_debug(3, "Set color to: %g %g %g", CAIROCOLOR(r), CAIROCOLOR(g),
00021                 CAIROCOLOR(b));
00022     }
00023 }
00024 
00025 int Cairo_lookup_color(int r, int g, int b)
00026 {
00027     G_debug(3, "Cairo_lookup_color: %d %d %d", r, g, b);
00028 
00029     return (r << 16) + (g << 8) + (b << 0);
00030 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines