1 /* Copyright (C) 2001-2006 Artifex Software, Inc.
2 All Rights Reserved.
3
4 This software is provided AS-IS with no warranty, either express or
5 implied.
6
7 This software is distributed under license and may not be copied, modified
8 or distributed except as expressly authorized under the terms of that
9 license. Refer to licensing information at http://www.artifex.com/
10 or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11 San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
12 */
13
14 /* $Id: zhsb.c 9043 2008-08-28 22:48:19Z giles $ */
15 /* HSB color operators */
16 #include "ghost.h"
17 #include "oper.h"
18 #include "igstate.h"
19 #include "store.h"
20 #include "gshsb.h"
21
22 /* - currenthsbcolor <hue> <saturation> <brightness> */
23 static int
zcurrenthsbcolor(i_ctx_t * i_ctx_p)24 zcurrenthsbcolor(i_ctx_t *i_ctx_p)
25 {
26 os_ptr op = osp;
27 float par[3];
28
29 gs_currenthsbcolor(igs, par);
30 push(3);
31 make_floats(op - 2, par, 3);
32 return 0;
33 }
34
35 /* <hue> <saturation> <brightness> sethsbcolor - */
36 static int
zsethsbcolor(i_ctx_t * i_ctx_p)37 zsethsbcolor(i_ctx_t *i_ctx_p)
38 {
39 os_ptr op = osp;
40 double par[3];
41 int code;
42
43 if ((code = num_params(op, 3, par)) < 0 ||
44 (code = gs_sethsbcolor(igs, par[0], par[1], par[2])) < 0
45 )
46 return code;
47 make_null(&istate->colorspace.array);
48 pop(3);
49 return 0;
50 }
51
52 /* ------ Initialization procedure ------ */
53
54 const op_def zhsb_op_defs[] =
55 {
56 {"0currenthsbcolor", zcurrenthsbcolor},
57 {"3sethsbcolor", zsethsbcolor},
58 op_def_end(0)
59 };
60