aboutsummaryrefslogtreecommitdiff
path: root/generic/Arc.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/Arc.c')
-rw-r--r--generic/Arc.c93
1 files changed, 90 insertions, 3 deletions
diff --git a/generic/Arc.c b/generic/Arc.c
index 2b5f7fa..b6b0252 100644
--- a/generic/Arc.c
+++ b/generic/Arc.c
@@ -1184,10 +1184,97 @@ GetAnchor(ZnItem item,
*
**********************************************************************************
*/
-static void
-PostScript(ZnItem item,
- ZnBool prepass)
+static int
+PostScript(ZnItem item,
+ ZnBool prepass,
+ ZnBBox *area)
{
+ ArcItem arc = (ArcItem) item;
+ ZnWInfo *wi = item->wi;
+ ZnPoint *p;
+ int i, num_points;
+ char path[500];
+
+ if (ISCLEAR(arc->flags, FILLED_BIT) && !arc->line_width) {
+ return TCL_OK;
+ }
+
+ /*
+ * Create the arc path.
+ */
+ if (ISSET(arc->flags, USING_POLY_BIT)) {
+ p = ZnListArray(arc->render_shape);
+ num_points = ZnListSize(arc->render_shape);
+ sprintf(path, "%.15g %.15g moveto ", p[0].x, p[0].y);
+ Tcl_AppendResult(wi->interp, path, NULL);
+ for (i = 0; i < num_points; i++) {
+ sprintf(path, "%.15g %.15g lineto ", p[i].x, p[i].y);
+ Tcl_AppendResult(wi->interp, path, NULL);
+ }
+ Tcl_AppendResult(wi->interp, "closepath\n", NULL);
+ }
+ else {
+ sprintf(path,
+ "matrix currentmatrix\n%.15g %.15g translate %.15g %.15g scale 1 0 moveto 0 0 1 0 360 arc\nsetmatrix\n",
+ (arc->corner.x + arc->orig.x) / 2.0, (arc->corner.y + arc->orig.y) / 2.0,
+ (arc->corner.x - arc->orig.x) / 2.0, (arc->corner.y - arc->orig.y) / 2.0);
+ Tcl_AppendResult(wi->interp, path, NULL);
+ }
+
+ /*
+ * Emit code to draw the filled area.
+ */
+ if (ISSET(arc->flags, FILLED_BIT)) {
+ if (arc->line_width) {
+ Tcl_AppendResult(wi->interp, "gsave\n", NULL);
+ }
+ if (!ZnGradientFlat(arc->fill_color)) {
+ if (ZnPostscriptGradient(wi->interp, wi->ps_info, arc->fill_color,
+ arc->grad_geo, NULL) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ }
+ else if (arc->tile != ZnUnspecifiedImage) {
+ if (!ZnImageIsBitmap(arc->tile)) { /* Fill tiled */
+ /* TODO No support yet */
+ }
+ else { /* Fill stippled */
+ if (Tk_PostscriptColor(wi->interp, wi->ps_info,
+ ZnGetGradientColor(arc->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(arc->tile, wi->win)) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ }
+ }
+ else { /* Fill solid */
+ if (Tk_PostscriptColor(wi->interp, wi->ps_info,
+ ZnGetGradientColor(arc->fill_color, 0.0, NULL)) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ Tcl_AppendResult(wi->interp, "fill\n", NULL);
+ }
+ if (arc->line_width) {
+ Tcl_AppendResult(wi->interp, "grestore\n", NULL);
+ }
+ }
+
+ /*
+ * Then emit code code to stroke the outline.
+ */
+ if (arc->line_width) {
+ Tcl_AppendResult(wi->interp, "0 setlinejoin 2 setlinecap\n", NULL);
+ if (ZnPostscriptOutline(wi->interp, wi->ps_info, wi->win,
+ arc->line_width, arc->line_style,
+ arc->line_color, arc->line_pattern) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ }
+
+ return TCL_OK;
}