1 /* Copyright (C) 1997 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: gsalpha.c,v 1.4 2002/02/21 22:24:52 giles Exp $ */
18 /* Graphics state alpha value access */
19 #include "gx.h"
20 #include "gsalpha.h"
21 #include "gxdcolor.h"
22 #include "gzstate.h"
23
24 /* setalpha */
25 int
gs_setalpha(gs_state * pgs,floatp alpha)26 gs_setalpha(gs_state * pgs, floatp alpha)
27 {
28 pgs->alpha =
29 (gx_color_value) (alpha < 0 ? 0 : alpha > 1 ? gx_max_color_value :
30 alpha * gx_max_color_value);
31 gx_unset_dev_color(pgs);
32 return 0;
33 }
34
35 /* currentalpha */
36 float
gs_currentalpha(const gs_state * pgs)37 gs_currentalpha(const gs_state * pgs)
38 {
39 return (float)pgs->alpha / gx_max_color_value;
40 }
41