aboutsummaryrefslogtreecommitdiff
path: root/generic/Rectangle.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/Rectangle.c')
-rw-r--r--generic/Rectangle.c83
1 files changed, 80 insertions, 3 deletions
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;
}