diff options
author | lecoanet | 2005-05-10 07:59:48 +0000 |
---|---|---|
committer | lecoanet | 2005-05-10 07:59:48 +0000 |
commit | 79f65d040d72f778f66f8eefdaffb6acd9799a38 (patch) | |
tree | d1e43508242bd9d6ba85e4147e444d12830b8d3a /generic/Curve.c | |
parent | 72fd6b4d5f695731d2b6f4c553f7f9bcd0c43476 (diff) | |
download | tkzinc-79f65d040d72f778f66f8eefdaffb6acd9799a38.zip tkzinc-79f65d040d72f778f66f8eefdaffb6acd9799a38.tar.gz tkzinc-79f65d040d72f778f66f8eefdaffb6acd9799a38.tar.bz2 tkzinc-79f65d040d72f778f66f8eefdaffb6acd9799a38.tar.xz |
Merge of the newly developped postscript code (still not fully functional).
Diffstat (limited to 'generic/Curve.c')
-rw-r--r-- | generic/Curve.c | 97 |
1 files changed, 94 insertions, 3 deletions
diff --git a/generic/Curve.c b/generic/Curve.c index 7054e81..c73d467 100644 --- a/generic/Curve.c +++ b/generic/Curve.c @@ -1578,10 +1578,101 @@ Pick(ZnItem item, * ********************************************************************************** */ -static void -PostScript(ZnItem item, - ZnBool prepass) +static int +PostScript(ZnItem item, + ZnBool prepass, + ZnBBox *area) { + ZnWInfo *wi = item->wi; + CurveItem cv = (CurveItem) item; + char path[500]; + ZnContour *contours; + ZnPoint *points; + int num_contours, num_points; + int i, j; + + num_contours = cv->outlines.num_contours; + contours = cv->outlines.contours; + + /* + * Put all contours in an array on the stack + */ + if (ISSET(cv->flags, FILLED_BIT) || cv->line_width) { + Tcl_AppendResult(wi->interp, "newpath ", NULL); + for (i = 0; i < num_contours; i++, contours++) { + num_points = contours->num_points; + points = contours->points; + sprintf(path, "%.15g %.15g moveto\n", points[0].x, points[0].y); + Tcl_AppendResult(wi->interp, path, NULL); + for (j = 1; j < num_points; j++) { + sprintf(path, "%.15g %.15g lineto ", points[j].x, points[j].y); + Tcl_AppendResult(wi->interp, path, NULL); + if (((j+1) % 5) == 0) { + Tcl_AppendResult(wi->interp, "\n", NULL); + } + } + } + } + + /* + * Emit code to draw the filled area. + */ + if (ISSET(cv->flags, FILLED_BIT)) { + if (cv->line_width) { + Tcl_AppendResult(wi->interp, "gsave\n", NULL); + } + if (!ZnGradientFlat(cv->fill_color)) { + if (ZnPostscriptGradient(wi->interp, wi->ps_info, cv->fill_color, + cv->grad_geo, NULL) != TCL_OK) { + return TCL_ERROR; + } + } + else if (cv->tile != ZnUnspecifiedImage) { + if (!ZnImageIsBitmap(cv->tile)) { /* Fill tiled */ + /* TODO No support yet */ + } + else { /* Fill stippled */ + if (Tk_PostscriptColor(wi->interp, wi->ps_info, + ZnGetGradientColor(cv->fill_color, 0.0, NULL)) != TCL_OK) { + return TCL_ERROR; + } + Tcl_AppendResult(wi->interp, "clip ", NULL); + if (Tk_PostscriptStipple(wi->interp, wi->win, wi->ps_info, + ZnImagePixmap(cv->tile, wi->win)) != TCL_OK) { + return TCL_ERROR; + } + } + } + else { /* Fill solid */ + if (Tk_PostscriptColor(wi->interp, wi->ps_info, + ZnGetGradientColor(cv->fill_color, 0.0, NULL)) != TCL_OK) { + return TCL_ERROR; + } + Tcl_AppendResult(wi->interp, "fill\n", NULL); + } + if (cv->line_width) { + Tcl_AppendResult(wi->interp, "grestore\n", NULL); + } + } + + /* + * Then emit code code to stroke the outline. + */ + if (cv->line_width) { + if (cv->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, + cv->line_width, cv->line_style, + cv->line_color, cv->line_pattern) != TCL_OK) { + return TCL_ERROR; + } + } + } + + return TCL_OK; } |