3 /* <groff_src_dir>/src/include/color.h
5 Last update: 5 Jan 2009
7 Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation, Inc.
8 Written by Gaius Mulley <gaius@glam.ac.uk>
10 This file is part of groff.
12 groff is free software; you can redistribute it and/or modify it under
13 the terms of the GNU General Public License as published by the Free
14 Software Foundation, either version 3 of the License, or
15 (at your option) any later version.
17 groff is distributed in the hope that it will be useful, but WITHOUT ANY
18 WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>. */
28 enum color_scheme {DEFAULT, CMY, CMYK, RGB, GRAY};
33 unsigned int components[4];
35 static color *free_list;
37 int read_encoding(const color_scheme, const char * const,
42 enum {MAX_COLOR_VAL = 0xffff};
43 color(symbol s = default_symbol) : scheme(DEFAULT), nm(s) {}
44 color(const color * const);
46 void *operator new(size_t);
47 void operator delete(void *);
49 int operator==(const color & c) const;
50 int operator!=(const color & c) const;
52 int is_default() { return scheme == DEFAULT; }
54 // set color from given color component values
56 void set_rgb(const unsigned int r, const unsigned int g,
57 const unsigned int b);
58 void set_cmy(const unsigned int c, const unsigned int m,
59 const unsigned int y);
60 void set_cmyk(const unsigned int c, const unsigned int m,
61 const unsigned int y, const unsigned int k);
62 void set_gray(const unsigned int g);
64 // set color from a color string
65 int read_rgb(const char * const s);
66 int read_cmy(const char * const s);
67 int read_cmyk(const char * const s);
68 int read_gray(const char * const s);
70 // Return the actual color scheme and retrieve the color components
71 // into a predefined vector (of length at least 4).
72 color_scheme get_components(unsigned int *c) const;
74 // retrieve the components of a color
75 void get_rgb(unsigned int *r, unsigned int *g, unsigned int *b) const;
76 void get_cmy(unsigned int *c, unsigned int *m, unsigned int *y) const;
77 void get_cmyk(unsigned int *c, unsigned int *m,
78 unsigned int *y, unsigned int *k) const;
79 void get_gray(unsigned int *g) const;
84 #define Cyan components[0]
85 #define Magenta components[1]
86 #define Yellow components[2]
87 #define Black components[3]
89 #define Red components[0]
90 #define Green components[1]
91 #define Blue components[2]
93 #define Gray components[0]
95 extern color default_color;