zhsb.c 1.6 KB

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