]> granicus.if.org Git - imagemagick/commitdiff
A rectangle with a width and height of 1 is a point
authorCristy <urban-warrior@imagemagick.org>
Mon, 28 May 2018 21:47:58 +0000 (17:47 -0400)
committerCristy <urban-warrior@imagemagick.org>
Mon, 28 May 2018 21:47:58 +0000 (17:47 -0400)
MagickCore/draw.c
MagickWand/drawing-wand.c
coders/svg.c

index 0dad9ff6b415212afe8cd1b687d8c42e65fa3694..a2ca20825efeeb3a45336faeeeee504d7ce5c32a 100644 (file)
@@ -6625,14 +6625,12 @@ static void TraceRectangle(PrimitiveInfo *primitive_info,const PointInfo start,
   TracePoint(p,start);
   p+=p->coordinates;
   point.x=start.x;
-  point.y=end.y-1.0;
+  point.y=end.y;
   TracePoint(p,point);
   p+=p->coordinates;
-  point.x=end.x-1.0;
-  point.y=end.y-1.0;
-  TracePoint(p,point);
+  TracePoint(p,end);
   p+=p->coordinates;
-  point.x=end.x-1.0;
+  point.x=end.x;
   point.y=start.y;
   TracePoint(p,point);
   p+=p->coordinates;
index 4ced8b77b4e2044bb990a1e92a042df7b6c49d45..a672fcdf3a363e2b158fd551449a8f3af280b91e 100644 (file)
@@ -4254,7 +4254,10 @@ WandExport void DrawRectangle(DrawingWand *wand,const double x1,const double y1,
   assert(wand->signature == MagickWandSignature);
   if (wand->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
-  (void) MVGPrintf(wand,"rectangle %.20g %.20g %.20g %.20g\n",x1,y1,x2,y2);
+  if ((fabs(x2-x1) < MagickEpsilon) && (fabs(y2-y1) < MagickEpsilon))
+    (void) MVGPrintf(wand,"point %.20g %.20g\n",x1,y1);
+  else
+   (void) MVGPrintf(wand,"rectangle %.20g %.20g %.20g %.20g\n",x1,y1,x2,y2);
 }
 \f
 /*
index b8152854c7832a6ded96a7bd7d0496eebeda57a4..011129cee9ea41e00806d871aefb51618fc2bb71 100644 (file)
@@ -2516,10 +2516,15 @@ static void SVGEndElement(void *context,const xmlChar *name)
           if ((svg_info->radius.x == 0.0) && (svg_info->radius.y == 0.0))
             {
               (void) FormatLocaleFile(svg_info->file,"class \"rect\"\n");
-              (void) FormatLocaleFile(svg_info->file,"rectangle %g,%g %g,%g\n",
-                svg_info->bounds.x,svg_info->bounds.y,
-                svg_info->bounds.x+svg_info->bounds.width,
-                svg_info->bounds.y+svg_info->bounds.height);
+              if ((fabs(svg_info->bounds.width-1.0) < MagickEpsilon) &&
+                  (fabs(svg_info->bounds.height-1.0) < MagickEpsilon))
+                (void) FormatLocaleFile(svg_info->file,"point %g,%g\n",
+                  svg_info->bounds.x,svg_info->bounds.y);
+              else
+                (void) FormatLocaleFile(svg_info->file,
+                  "rectangle %g,%g %g,%g\n",svg_info->bounds.x,
+                  svg_info->bounds.y,svg_info->bounds.x+svg_info->bounds.width,
+                  svg_info->bounds.y+svg_info->bounds.height);
               (void) FormatLocaleFile(svg_info->file,"pop graphic-context\n");
               break;
             }