1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
4 * (GLABELS) Label and Business Card Creation program for GNOME
6 * color.h: various small utilities for dealing with canvas colors
8 * Copyright (C) 2002-2007 Jim Evins <evins@snaught.com>.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include <gdk/gdkcolor.h>
34 * gLabels stores colors as a 32-bit unsigned integer in RGBA format (MSByte = Red)
36 #define GL_COLOR(r,g,b) ( (((unsigned int) (r) & 0xff) << 24) \
37 | (((unsigned int) (g) & 0xff) << 16) \
38 | (((unsigned int) (b) & 0xff) << 8) \
41 #define GL_COLOR_A(r,g,b,a) ( (((unsigned int) (r) & 0xff) << 24) \
42 | (((unsigned int) (g) & 0xff) << 16) \
43 | (((unsigned int) (b) & 0xff) << 8) \
44 | ( (unsigned int) (a) & 0xff ) )
47 #define GL_COLOR_NONE GL_COLOR_A(0,0,0,0)
48 #define GL_COLOR_FILL_MERGE_DEFAULT GL_COLOR_A(255,255,255,128)
49 #define GL_COLOR_MERGE_DEFAULT GL_COLOR_A(0,0,0,128)
50 #define GL_COLOR_SHADOW_DEFAULT GL_COLOR(0,0,0)
51 #define GL_COLOR_SHADOW_MERGE_DEFAULT GL_COLOR_A(0,0,0,255)
55 * Extract components as floating point (0.0 .. 1.0)
57 #define GL_COLOR_F_RED(x) ( (((x)>>24) & 0xff) / 255.0 )
58 #define GL_COLOR_F_GREEN(x) ( (((x)>>16) & 0xff) / 255.0 )
59 #define GL_COLOR_F_BLUE(x) ( (((x)>>8) & 0xff) / 255.0 )
60 #define GL_COLOR_F_ALPHA(x) ( ( (x) & 0xff) / 255.0 )
63 * Extract arguments for cairo_set_source_rgb()
65 #define GL_COLOR_RGB_ARGS(x) \
67 GL_COLOR_F_GREEN(x), \
71 * Extract arguments for cairo_set_source_rgba()
73 #define GL_COLOR_RGBA_ARGS(x) \
75 GL_COLOR_F_GREEN(x), \
82 guint gl_color_set_opacity (guint color,
85 guint gl_color_shadow (guint base_color,
90 * Routines to convert to/from GdkColor.
92 GdkColor *gl_color_to_gdk_color (guint color);
94 guint gl_color_from_gdk_color (GdkColor *gdk_color);
107 glColorNode *gl_color_node_new_default (void);
109 glColorNode *gl_color_node_dup (glColorNode *color_node);
110 gboolean gl_color_node_equal (glColorNode *color_node1,
111 glColorNode *color_node2);
112 guint gl_color_node_expand (glColorNode *color_node,
113 glMergeRecord *record);
114 void gl_color_node_free (glColorNode **color_node);
119 #endif /* __COLOR_H__ */