xref: /plan9/sys/src/cmd/gs/src/zhsb.c (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1994, 1997, 1999 Aladdin Enterprises.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: zhsb.c,v 1.4 2002/02/21 22:24:54 giles Exp $ */
18 /* HSB color operators */
19 #include "ghost.h"
20 #include "oper.h"
21 #include "igstate.h"
22 #include "store.h"
23 #include "gshsb.h"
24 
25 /* - currenthsbcolor <hue> <saturation> <brightness> */
26 private int
zcurrenthsbcolor(i_ctx_t * i_ctx_p)27 zcurrenthsbcolor(i_ctx_t *i_ctx_p)
28 {
29     os_ptr op = osp;
30     float par[3];
31 
32     gs_currenthsbcolor(igs, par);
33     push(3);
34     make_floats(op - 2, par, 3);
35     return 0;
36 }
37 
38 /* <hue> <saturation> <brightness> sethsbcolor - */
39 private int
zsethsbcolor(i_ctx_t * i_ctx_p)40 zsethsbcolor(i_ctx_t *i_ctx_p)
41 {
42     os_ptr op = osp;
43     double par[3];
44     int code;
45 
46     if ((code = num_params(op, 3, par)) < 0 ||
47 	(code = gs_sethsbcolor(igs, par[0], par[1], par[2])) < 0
48 	)
49 	return code;
50     make_null(&istate->colorspace.array);
51     pop(3);
52     return 0;
53 }
54 
55 /* ------ Initialization procedure ------ */
56 
57 const op_def zhsb_op_defs[] =
58 {
59     {"0currenthsbcolor", zcurrenthsbcolor},
60     {"3sethsbcolor", zsethsbcolor},
61     op_def_end(0)
62 };
63