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/Triangles.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 3 deletions(-) (limited to 'generic/Triangles.c') diff --git a/generic/Triangles.c b/generic/Triangles.c index 4b3b8bb..1565b5b 100644 --- a/generic/Triangles.c +++ b/generic/Triangles.c @@ -573,10 +573,62 @@ Pick(ZnItem item, * ********************************************************************************** */ -static void -PostScript(ZnItem item, - ZnBool prepass) +static int +PostScript(ZnItem item, + ZnBool prepass, + ZnBBox *area) { + ZnWInfo *wi = item->wi; + TrianglesItem tr = (TrianglesItem) item; + ZnPoint *points; + int i, num_points, last_color_index; + int edge; + ZnGradient **grads; + XColor *color = NULL; + double red, green, blue; + ZnBBox bbox; + char path[150]; + + points = tr->dev_points.strips->points; + num_points = tr->dev_points.strips->num_points; + ZnResetBBox(&bbox); + ZnAddPointsToBBox(&bbox, points, num_points); + + grads = ZnListArray(tr->colors); + last_color_index = ZnListSize(tr->colors)-1; + + Tcl_AppendResult(wi->interp, + "/ShadingDict <<\n /ShadingType 4\n /ColorSpace /DeviceRGB\n", + " /DataSource [", NULL); + for (i = 0; i < num_points; i++) { + if (i <= last_color_index) { + color = ZnGetGradientColor(grads[i], 0.0, NULL); + } + if (i < 3) { + edge = 0; + } + else if (ISCLEAR(tr->flags, FAN_BIT)) { + edge = 1; + } + else { + edge = 2; + } + red = ((double) (color->red >> 8)) / 255.0; + green = ((double) (color->green >> 8)) / 255.0; + blue = ((double) (color->blue >> 8)) / 255.0; + + sprintf(path, "%d %.15g %.15g %.4g %.4g %.4g ", + edge, points[i].x, points[i].y, red, green, blue); + Tcl_AppendResult(wi->interp, path, NULL); + } + Tcl_AppendResult(wi->interp, "]\n>> def\n", NULL); + Tcl_AppendResult(wi->interp, "<<\n /PatternType 2\n /Shading ShadingDict\n>>\n", NULL); + Tcl_AppendResult(wi->interp, "matrix identmatrix makepattern setpattern\n", NULL); + sprintf(path, "%.15g %.15g %.15g %.15g rectfill\n", bbox.orig.x, bbox.orig.y, + bbox.corner.x - bbox.orig.x, bbox.corner.y - bbox.orig.y); + Tcl_AppendResult(wi->interp, path, NULL); + + return TCL_OK; } -- cgit v1.1