|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T z
Length: 3502 (0xdae) Types: TextFile Names: »zcolor.c«
└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89 └─⟦ff23ba0e6⟧ »./ghostscript-1.3.tar.Z« └─⟦a24a58cd3⟧ └─⟦this⟧ »zcolor.c«
/* Copyright (C) 1989 Aladdin Enterprises. All rights reserved. Distributed by Free Software Foundation, Inc. This file is part of Ghostscript. Ghostscript is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. No author or distributor accepts responsibility to anyone for the consequences of using it or for whether it serves any particular purpose or works at all, unless he says so in writing. Refer to the Ghostscript General Public License for full details. Everyone is granted permission to copy, modify and redistribute Ghostscript, but only under the conditions described in the Ghostscript General Public License. A copy of this license is supposed to have been given to you along with Ghostscript so you can know your rights and responsibilities. It should be in a file named COPYING. Among other things, the copyright notice and this notice must be preserved on all copies. */ /* zcolor.c */ /* Color operators for GhostScript */ #include "ghost.h" #include "errors.h" #include "oper.h" #include "alloc.h" #include "store.h" #include "gsmatrix.h" /* for gs_state */ #include "gsstate.h" #include "state.h" /* Imported from util.c */ extern int num_params(P3(ref *, int, float *)); /* Imported from zgstate.c */ extern void tri_push(P2(ref *, float [3])); /* Forward declarations */ private int color_to_par(P2(ref *, int (*)(P2(gs_color *, float [3])))); private int par_to_color(P2(ref *, int (*)(P4(floatp, floatp, floatp, gs_color *)))); private int make_color(P1(ref *)); /* colorhsb */ int zcolorhsb(register ref *op) { return color_to_par(op, gs_colorhsb); } /* colorrgb */ int zcolorrgb(register ref *op) { return color_to_par(op, gs_colorrgb); } /* Common code for colorhsb and colorrgb */ private int color_to_par(ref *op, int (*c2par)(P2(gs_color *, float [3]))) { int code; float par[3]; check_type(*op, t_color); if ( (code = (*c2par)(op->value.pcolor, par)) < 0 ) return code; push(2); tri_push(op, par); return 0; } /* currentcolor */ int zcurrentcolor(register ref *op) { int code; push(1); if ( (code = make_color(op)) < 0 || (code = gs_currentcolor(igs, op->value.pcolor)) < 0 ) pop(1); return code; } /* hsbcolor */ int zhsbcolor(register ref *op) { return par_to_color(op, gs_hsbcolor); } /* rgbcolor */ int zrgbcolor(register ref *op) { return par_to_color(op, gs_rgbcolor); } /* Common code for hsbcolor and rgbcolor */ private int par_to_color(ref *op, int (*par2c)(P4(floatp, floatp, floatp, gs_color *))) { ref color; float par[3]; int code; if ( (code = num_params(op, 3, par)) < 0 || (code = make_color(&color)) < 0 || (code = (*par2c)(par[0], par[1], par[2], color.value.pcolor)) < 0 ) return code; op[-2] = color; pop(2); return code; } /* setcolor */ int zsetcolor(register ref *op) { int code; check_type(*op, t_color); if ( (code = gs_setcolor(igs, op->value.pcolor)) < 0 ) return code; pop(1); return 0; } /* ------ Initialization procedure ------ */ void zcolor_op_init() { static op_def my_defs[] = { {"1colorhsb", zcolorhsb}, {"1colorrgb", zcolorrgb}, {"0currentcolor", zcurrentcolor}, {"3hsbcolor", zhsbcolor}, {"3rgbcolor", zrgbcolor}, {"1setcolor", zsetcolor}, op_def_end }; z_op_init(my_defs); } /* ------ Internal routines ------ */ /* Make a color object */ private int make_color(ref *op) { gs_color *cp = (gs_color *)alloc(gs_color_sizeof, "make_color"); if ( cp == 0 ) return e_VMerror; make_tv(op, t_color, pcolor, cp); return 0; }