From 79f65d040d72f778f66f8eefdaffb6acd9799a38 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Tue, 10 May 2005 07:59:48 +0000 Subject: Merge of the newly developped postscript code (still not fully functional). --- generic/Rectangle.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 3 deletions(-) (limited to 'generic/Rectangle.c') diff --git a/generic/Rectangle.c b/generic/Rectangle.c index 7cf4f8d..8afb38f 100644 --- a/generic/Rectangle.c +++ b/generic/Rectangle.c @@ -753,10 +753,87 @@ Pick(ZnItem item, * ********************************************************************************** */ -static void -PostScript(ZnItem item, - ZnBool prepass) +static int +PostScript(ZnItem item, + ZnBool prepass, + ZnBBox *area) { + ZnWInfo *wi = item->wi; + RectangleItem rect = (RectangleItem) item; + char path[500]; + + if (ISCLEAR(rect->flags, FILLED_BIT) && (rect->line_width == 0)) { + return TCL_OK; + } + + /* + * Create the rectangle path. + */ + sprintf(path, "%.15g %.15g moveto %.15g %.15g lineto %.15g %.15g lineto %.15g %.15g lineto closepath\n", + rect->dev[0].x, rect->dev[0].y, rect->dev[1].x, rect->dev[1].y, + rect->dev[2].x, rect->dev[2].y, rect->dev[3].x, rect->dev[3].y); + Tcl_AppendResult(wi->interp, path, NULL); + + /* + * Emit code to draw the filled area. + */ + if (ISSET(rect->flags, FILLED_BIT)) { + if (rect->line_width) { + Tcl_AppendResult(wi->interp, "gsave\n", NULL); + } + if (!ZnGradientFlat(rect->fill_color)) { + if (ZnPostscriptGradient(wi->interp, wi->ps_info, rect->fill_color, + rect->grad_geo ? rect->grad_geo : rect->dev, NULL) != TCL_OK) { + return TCL_ERROR; + } + } + else if (rect->tile != ZnUnspecifiedImage) { + if (!ZnImageIsBitmap(rect->tile)) { /* Fill tiled */ + if (ZnPostscriptTile(wi->interp, wi->win, wi->ps_info, rect->tile) != TCL_OK) { + return TCL_ERROR; + } + } + else { /* Fill stippled */ + if (Tk_PostscriptColor(wi->interp, wi->ps_info, + ZnGetGradientColor(rect->fill_color, 0.0, NULL)) != TCL_OK) { + return TCL_ERROR; + } + Tcl_AppendResult(wi->interp, "clip ", NULL); + if (ZnPostscriptStipple(wi->interp, wi->win, wi->ps_info, rect->tile) != TCL_OK) { + return TCL_ERROR; + } + } + } + else { /* Fill solid */ + if (Tk_PostscriptColor(wi->interp, wi->ps_info, + ZnGetGradientColor(rect->fill_color, 0.0, NULL)) != TCL_OK) { + return TCL_ERROR; + } + Tcl_AppendResult(wi->interp, "fill\n", NULL); + } + if (rect->line_width) { + Tcl_AppendResult(wi->interp, "grestore\n", NULL); + } + } + + /* + * Then emit code code to stroke the outline. + */ + if (rect->line_width) { + if (rect->relief != ZN_RELIEF_FLAT) { + /* TODO No support yet */ + } + else { + Tcl_AppendResult(wi->interp, "0 setlinejoin 2 setlinecap\n", NULL); + if (ZnPostscriptOutline(wi->interp, wi->ps_info, wi->win, + rect->line_width, rect->line_style, + rect->line_color, rect->line_pattern) != TCL_OK) { + return TCL_ERROR; + } + } + } + + return TCL_OK; } -- cgit v1.1