2 /* <groff_src_dir>/src/include/color.h
3 Copyright (C) 2001-2018 Free Software Foundation, Inc.
4 Written by Gaius Mulley <gaius@glam.ac.uk>
6 This file is part of groff.
8 groff is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 groff is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 enum color_scheme {DEFAULT, CMY, CMYK, RGB, GRAY};
29 unsigned int components[4];
32 int read_encoding(const color_scheme, const char * const,
37 enum {MAX_COLOR_VAL = 0xffff};
38 color(symbol s = default_symbol) : scheme(DEFAULT), nm(s) {}
39 color(const color * const);
42 int operator==(const color & c) const;
43 int operator!=(const color & c) const;
45 int is_default() { return scheme == DEFAULT; }
47 // set color from given color component values
49 void set_rgb(const unsigned int r, const unsigned int g,
50 const unsigned int b);
51 void set_cmy(const unsigned int c, const unsigned int m,
52 const unsigned int y);
53 void set_cmyk(const unsigned int c, const unsigned int m,
54 const unsigned int y, const unsigned int k);
55 void set_gray(const unsigned int g);
57 // set color from a color string
58 int read_rgb(const char * const s);
59 int read_cmy(const char * const s);
60 int read_cmyk(const char * const s);
61 int read_gray(const char * const s);
63 // Return the actual color scheme and retrieve the color components
64 // into a predefined vector (of length at least 4).
65 color_scheme get_components(unsigned int *c) const;
67 // retrieve the components of a color
68 void get_rgb(unsigned int *r, unsigned int *g, unsigned int *b) const;
69 void get_cmy(unsigned int *c, unsigned int *m, unsigned int *y) const;
70 void get_cmyk(unsigned int *c, unsigned int *m,
71 unsigned int *y, unsigned int *k) const;
72 void get_gray(unsigned int *g) const;
77 #define Cyan components[0]
78 #define Magenta components[1]
79 #define Yellow components[2]
80 #define Black components[3]
82 #define Red components[0]
83 #define Green components[1]
84 #define Blue components[2]
86 #define Gray components[0]
88 extern color default_color;