aboutsummaryrefslogtreecommitdiff
path: root/generic/Curve.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/Curve.c')
-rw-r--r--generic/Curve.c97
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;
}