Graphviz  2.29.20120523.0446
lib/common/color.h
Go to the documentation of this file.
00001 /* $Id$ $Revision$ */
00002 /* vim:set shiftwidth=4 ts=8: */
00003 
00004 /*************************************************************************
00005  * Copyright (c) 2011 AT&T Intellectual Property 
00006  * All rights reserved. This program and the accompanying materials
00007  * are made available under the terms of the Eclipse Public License v1.0
00008  * which accompanies this distribution, and is available at
00009  * http://www.eclipse.org/legal/epl-v10.html
00010  *
00011  * Contributors: See CVS logs. Details at http://www.graphviz.org/
00012  *************************************************************************/
00013 
00014 #ifndef GV_COLOR_H
00015 #define GV_COLOR_H
00016 
00017 /* #include "arith.h" */
00018 
00019 #ifdef __cplusplus
00020 extern "C" {
00021 #endif
00022 
00023 typedef struct hsvrgbacolor_t {
00024     char *name;
00025     unsigned char h, s, v;
00026     unsigned char r, g, b, a;
00027 } hsvrgbacolor_t;
00028 
00029 /* possible representations of color in gvcolor_t */
00030 typedef enum { HSVA_DOUBLE, RGBA_BYTE, RGBA_WORD, CMYK_BYTE,
00031                 RGBA_DOUBLE, COLOR_STRING, COLOR_INDEX } color_type_t;
00032 
00033 /* gvcolor_t can hold a color spec in a choice or representations */
00034 typedef struct color_s {
00035     union {
00036         double RGBA[4];
00037         double HSVA[4];
00038         unsigned char rgba[4];
00039         unsigned char cmyk[4];
00040         int rrggbbaa[4];
00041         char *string;
00042         int index;
00043     } u;
00044     color_type_t type;
00045 } gvcolor_t;
00046 
00047 #define COLOR_MALLOC_FAIL -1
00048 #define COLOR_UNKNOWN 1
00049 #define COLOR_OK 0
00050 
00051 #ifdef __cplusplus
00052 }
00053 #endif
00054 #endif