3 /* <groff_src_dir>/src/include/color.h
5 Last update: 14 Feb 2003
7 Copyright (C) 2001, 2002, 2003 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 2, or (at your option) any later
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 along
23 with groff; see the file COPYING. If not, write to the Free Software
24 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
29 enum color_scheme
{DEFAULT
, CMY
, CMYK
, RGB
, GRAY
};
34 unsigned int components
[4];
36 static color
*free_list
;
38 int read_encoding(const color_scheme
, const char * const,
43 enum {MAX_COLOR_VAL
= 0xffff};
44 color(symbol s
= default_symbol
) : scheme(DEFAULT
), nm(s
) {}
45 color(const color
* const);
47 void *operator new(size_t);
48 void operator delete(void *);
50 int operator==(const color
& c
) const;
51 int operator!=(const color
& c
) const;
53 int is_default() { return scheme
== DEFAULT
; }
55 // set color from given color component values
57 void set_rgb(const unsigned int r
, const unsigned int g
,
58 const unsigned int b
);
59 void set_cmy(const unsigned int c
, const unsigned int m
,
60 const unsigned int y
);
61 void set_cmyk(const unsigned int c
, const unsigned int m
,
62 const unsigned int y
, const unsigned int k
);
63 void set_gray(const unsigned int g
);
65 // set color from a color string
66 int read_rgb(const char * const s
);
67 int read_cmy(const char * const s
);
68 int read_cmyk(const char * const s
);
69 int read_gray(const char * const s
);
71 // Return the actual color scheme and retrieve the color components
72 // into a predefined vector (of length at least 4).
73 color_scheme
get_components(unsigned int *c
) const;
75 // retrieve the components of a color
76 void get_rgb(unsigned int *r
, unsigned int *g
, unsigned int *b
) const;
77 void get_cmy(unsigned int *c
, unsigned int *m
, unsigned int *y
) const;
78 void get_cmyk(unsigned int *c
, unsigned int *m
,
79 unsigned int *y
, unsigned int *k
) const;
80 void get_gray(unsigned int *g
) const;
85 #define Cyan components[0]
86 #define Magenta components[1]
87 #define Yellow components[2]
88 #define Black components[3]
90 #define Red components[0]
91 #define Green components[1]
92 #define Blue components[2]
94 #define Gray components[0]
96 extern color default_color
;