From: ellson Date: Fri, 9 Jun 2006 20:24:33 +0000 (+0000) Subject: fix svg inversion and ps usershape size in ps X-Git-Tag: LAST_LIBGRAPH~32^2~6472 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a21d96188a3c40e093289bc0f76f336ff2b305f4;p=graphviz fix svg inversion and ps usershape size in ps --- diff --git a/lib/common/emit.c b/lib/common/emit.c index 96b50aaa2..843f5b847 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -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: diff --git a/lib/common/psgen.c b/lib/common/psgen.c index 8ace600b7..392b2b79e 100644 --- a/lib/common/psgen.c +++ b/lib/common/psgen.c @@ -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