From 1520a8e7bc42d254f3611cdeaaaf337392735c36 Mon Sep 17 00:00:00 2001 From: Cristy Date: Mon, 28 May 2018 17:47:58 -0400 Subject: [PATCH] A rectangle with a width and height of 1 is a point --- MagickCore/draw.c | 8 +++----- MagickWand/drawing-wand.c | 5 ++++- coders/svg.c | 13 +++++++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/MagickCore/draw.c b/MagickCore/draw.c index 0dad9ff6b..a2ca20825 100644 --- a/MagickCore/draw.c +++ b/MagickCore/draw.c @@ -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; diff --git a/MagickWand/drawing-wand.c b/MagickWand/drawing-wand.c index 4ced8b77b..a672fcdf3 100644 --- a/MagickWand/drawing-wand.c +++ b/MagickWand/drawing-wand.c @@ -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); } /* diff --git a/coders/svg.c b/coders/svg.c index b8152854c..011129cee 100644 --- a/coders/svg.c +++ b/coders/svg.c @@ -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; } -- 2.40.0