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: gsalpha.c 8022 2007-06-05 22:23:38Z giles $ */
15 /* Graphics state alpha value access */
16 #include "gx.h"
17 #include "gsalpha.h"
18 #include "gxdcolor.h"
19 #include "gzstate.h"
20
21 /* setalpha */
22 int
gs_setalpha(gs_state * pgs,floatp alpha)23 gs_setalpha(gs_state * pgs, floatp alpha)
24 {
25 pgs->alpha =
26 (gx_color_value) (alpha < 0 ? 0 : alpha > 1 ? gx_max_color_value :
27 alpha * gx_max_color_value);
28 gx_unset_dev_color(pgs);
29 return 0;
30 }
31
32 /* currentalpha */
33 float
gs_currentalpha(const gs_state * pgs)34 gs_currentalpha(const gs_state * pgs)
35 {
36 return (float)pgs->alpha / gx_max_color_value;
37 }
38