GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cairodriver/Color.c
Go to the documentation of this file.
1 #include "cairodriver.h"
2 
3 /* "cached" color (to avoid more color change calls than necessary) */
4 /* TODO: find a proper solution for initialization */
5 int previous_color = 0x7FFFFFFF;
6 
7 void Cairo_color(int color)
8 {
9  G_debug(3, "Cairo_color: %d", color);
10 
11  if (color != previous_color) {
12  int r = (color >> 16) & 0xFF;
13  int g = (color >> 8) & 0xFF;
14  int b = (color >> 0) & 0xFF;
15 
16  cairo_set_source_rgba(cairo, CAIROCOLOR(r), CAIROCOLOR(g),
17  CAIROCOLOR(b), 1.0);
19 
20  G_debug(3, "Set color to: %g %g %g", CAIROCOLOR(r), CAIROCOLOR(g),
21  CAIROCOLOR(b));
22  }
23 }
24 
25 int Cairo_lookup_color(int r, int g, int b)
26 {
27  G_debug(3, "Cairo_lookup_color: %d %d %d", r, g, b);
28 
29  return (r << 16) + (g << 8) + (b << 0);
30 }
float b
Definition: named_colr.c:8
#define CAIROCOLOR(a)
Definition: cairodriver.h:21
float r
Definition: named_colr.c:8
int Cairo_lookup_color(int, int, int)
tuple color
Definition: tools.py:1703
cairo_t * cairo
float g
Definition: named_colr.c:8
void Cairo_color(int)
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: gis/debug.c:51
int previous_color