]> granicus.if.org Git - graphviz/commitdiff
fix svg inversion and ps usershape size in ps
authorellson <devnull@localhost>
Fri, 9 Jun 2006 20:24:33 +0000 (20:24 +0000)
committerellson <devnull@localhost>
Fri, 9 Jun 2006 20:24:33 +0000 (20:24 +0000)
lib/common/emit.c
lib/common/psgen.c

index 96b50aaa2719a69bba0d6693d692dbb55ad7f812..843f5b8470051bb72b60b59ae1842576467a9632 100644 (file)
@@ -88,10 +88,10 @@ static void init_job_flags(GVJ_t * job, graph_t * g)
         job->flags = chkOrder(g) | job->render.features->flags;
         break;
     case POSTSCRIPT:
-        job->flags = chkOrder(g) | GVRENDER_DOES_MULTIGRAPH_OUTPUT_FILES;
+        job->flags = chkOrder(g) | GVRENDER_DOES_TRANSFORM | GVRENDER_DOES_MULTIGRAPH_OUTPUT_FILES;
         break;
     case SVG:
-        job->flags = chkOrder(g);
+        job->flags = chkOrder(g) | GVRENDER_Y_GOES_DOWN;
         break;
     case GD: /* bitmap formats supported by gdgen.c */
     case GD2:
index 8ace600b7fd85a2c46e739c1597927dd47b81f95..392b2b79ee85f8fe9bcc5a1eede1839bb831bf28 100644 (file)
@@ -491,17 +491,17 @@ static void ps_polyline(point * A, int n)
 }
 
 #ifdef HAVE_LIBGD
-static void writePSBitmap (gdImagePtr im, boxf b)
+static void writePSBitmap (gdImagePtr im, point p, pointf sz)
 {
     int x, y, px;
 
     fprintf(Output_file, "gsave\n");
 
     /* this sets the position of the image */
-    fprintf(Output_file, "%g %g translate %% lower-left coordinate\n", b.LL.x, b.LL.y);
+    fprintf(Output_file, "%d %d translate %% lower-left coordinate\n", p.x, p.y);
 
     /* this sets the rendered size to fit the box */
-    fprintf(Output_file,"%g %g scale\n", b.UR.x - b.LL.x, b.UR.y - b.LL.y);
+    fprintf(Output_file,"%g %g scale\n", sz.x, sz.y);
 
     /* xsize ysize bits-per-sample [matrix] */
     fprintf(Output_file, "%d %d 8 [%d 0 0 %d 0 %d]\n", im->sx, im->sy, 
@@ -672,7 +672,42 @@ static void ps_usershape(usershape_t *us, boxf b, point *A, int n, bool filled)
 
 #ifdef HAVE_LIBGD
     if (gd_img) {
-       writePSBitmap (gd_img, b);
+       point p;
+       pointf sz;
+       double tw, th;
+       double scalex, scaley;
+        sz.x = (double)(A[0].x - A[2].x);
+        sz.y = (double)(A[0].y - A[2].y);
+       scalex = sz.x / us->w;
+       scaley = sz.y / us->h;
+       if (scalex < scaley) {
+            tw = us->w * scalex;
+            th = us->h * scalex;
+        } else {
+            tw = us->w * scaley;
+            th = us->h * scaley;
+        }
+       p = A[2];
+       if (tw < sz.x) {
+           p.x = ROUND(A[2].x + (sz.x - tw) / 2.0);
+           sz.x = tw;
+       }
+       if (th < sz.y) {
+           p.y = ROUND(A[2].y + (sz.y - th) / 2.0);
+           sz.x = th;
+       }
+
+
+#if 0
+fprintf(stderr,"b = %g,%g,%g,%g\n", b.LL.x,b.LL.y,b.UR.x,b.UR.y);
+fprintf(stderr,"A = %d,%d,%d,%d,%d,%d,%d,%d\n",
+       A[0].x, A[0].y,
+       A[1].x, A[1].y,
+       A[2].x, A[2].y,
+       A[3].x, A[3].y);
+#endif
+        
+       writePSBitmap (gd_img, p, sz);
        return;
     }
 #endif