basegfx/source/polygon/b2dpolygontools.cxx | 4 +- include/basegfx/polygon/b2dpolygontools.hxx | 9 +++- svx/source/customshapes/EnhancedCustomShape2d.cxx | 40 ++-------------------- 3 files changed, 13 insertions(+), 40 deletions(-)
New commits: commit c4c1636b5132261e64492de38f252b19b77e69b8 Author: Regina Henschel <rb.hensc...@t-online.de> AuthorDate: Wed Nov 14 14:30:49 2018 +0100 Commit: Regina Henschel <rb.hensc...@t-online.de> CommitDate: Fri Nov 16 17:45:48 2018 +0100 tdf#121305 Increase accuracy of custom shape circle The old implementation has used 4 segments and a questionable control point distance. The patch changes this to use the common implementation in basegfx. The method in basegfx is extended to allow to set the start quarter, so that the custom shape circle can get the same start quarter as it has before. The method descriptions in basegfx are adapted to the current implementation. Change-Id: I3a40f81827227ee0037d336bdf3c1ec6fdd64b4b Reviewed-on: https://gerrit.libreoffice.org/63366 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.hensc...@t-online.de> diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index 5c8eaa5792a6..e0cfcdba1933 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -1768,9 +1768,9 @@ namespace basegfx } } - B2DPolygon createPolygonFromEllipse( const B2DPoint& rCenter, double fRadiusX, double fRadiusY ) + B2DPolygon createPolygonFromEllipse( const B2DPoint& rCenter, double fRadiusX, double fRadiusY, sal_uInt32 nStartQuadrant) { - B2DPolygon aRetval(createPolygonFromUnitCircle()); + B2DPolygon aRetval(createPolygonFromUnitCircle(nStartQuadrant)); const B2DHomMatrix aMatrix(createScaleTranslateB2DHomMatrix(fRadiusX, fRadiusY, rCenter.getX(), rCenter.getY())); aRetval.transform(aMatrix); diff --git a/include/basegfx/polygon/b2dpolygontools.hxx b/include/basegfx/polygon/b2dpolygontools.hxx index 2f5641bb1581..57b9130b4399 100644 --- a/include/basegfx/polygon/b2dpolygontools.hxx +++ b/include/basegfx/polygon/b2dpolygontools.hxx @@ -231,7 +231,7 @@ namespace basegfx /** Create a circle polygon with given radius. This method creates a circle approximation consisting of - four cubic bezier segments, which approximate the given + 12 cubic bezier segments, which approximate the given circle with an error of less than 0.5 percent. @param rCenter @@ -260,7 +260,7 @@ namespace basegfx /** Create an ellipse polygon with given radii. This method creates an ellipse approximation consisting of - four cubic bezier segments, which approximate the given + 12 cubic bezier segments, which approximate the given ellipse with an error of less than 0.5 percent. @param rCenter @@ -271,8 +271,11 @@ namespace basegfx @param fRadiusY Radius of the ellipse in Y direction + + @param nStartQuadrant + With Y down on screens, 0 = 3 o'clock, 1 = 6 o'clock, 2 = 9 o'clock, 3 = 12 o'clock */ - BASEGFX_DLLPUBLIC B2DPolygon createPolygonFromEllipse( const B2DPoint& rCenter, double fRadiusX, double fRadiusY ); + BASEGFX_DLLPUBLIC B2DPolygon createPolygonFromEllipse( const B2DPoint& rCenter, double fRadiusX, double fRadiusY, sal_uInt32 nStartQuadrant = 0); /** Create an unit ellipse polygon with the given angles, from start to end */ diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index 20e2da61d404..aaeac95f71db 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -1688,41 +1688,11 @@ void EnhancedCustomShape2d::CreateSubPath( aNewB2DPolygon.append(CreateArc( aRect, Point( static_cast<sal_Int32>(fx1), static_cast<sal_Int32>(fy1) ), Point( static_cast<sal_Int32>(fx2), static_cast<sal_Int32>(fy2) ), false)); } else - { /* SJ: TODO: this block should be replaced sometimes, because the current point - is not set correct, it also does not use the correct moveto - point if ANGLEELLIPSETO was used, but the method CreateArc - is at the moment not able to draw full circles (if startangle is 0 - and endangle 360 nothing is painted :-( */ - sal_Int32 nXControl = static_cast<sal_Int32>(static_cast<double>(aRect.GetWidth()) * 0.2835 ); - sal_Int32 nYControl = static_cast<sal_Int32>(static_cast<double>(aRect.GetHeight()) * 0.2835 ); - Point aCenter( aRect.Center() ); - - // append start point - aNewB2DPolygon.append(basegfx::B2DPoint(aCenter.X(), aRect.Top())); - - // append four bezier segments - aNewB2DPolygon.appendBezierSegment( - basegfx::B2DPoint(aCenter.X() + nXControl, aRect.Top()), - basegfx::B2DPoint(aRect.Right(), aCenter.Y() - nYControl), - basegfx::B2DPoint(aRect.Right(), aCenter.Y())); - - aNewB2DPolygon.appendBezierSegment( - basegfx::B2DPoint(aRect.Right(), aCenter.Y() + nYControl), - basegfx::B2DPoint(aCenter.X() + nXControl, aRect.Bottom()), - basegfx::B2DPoint(aCenter.X(), aRect.Bottom())); - - aNewB2DPolygon.appendBezierSegment( - basegfx::B2DPoint(aCenter.X() - nXControl, aRect.Bottom()), - basegfx::B2DPoint(aRect.Left(), aCenter.Y() + nYControl), - basegfx::B2DPoint(aRect.Left(), aCenter.Y())); - - aNewB2DPolygon.appendBezierSegment( - basegfx::B2DPoint(aRect.Left(), aCenter.Y() - nYControl), - basegfx::B2DPoint(aCenter.X() - nXControl, aRect.Top()), - basegfx::B2DPoint(aCenter.X(), aRect.Top())); - - // close, rescue last controlpoint, remove double last point - basegfx::utils::closeWithGeometryChange(aNewB2DPolygon); + { + basegfx::B2DPoint aEllipseCenter(aRect.Center().X(),aRect.Center().Y()); + double fRadiusX(aRect.GetWidth()/2.0); + double fRadiusY(aRect.GetHeight()/2.0); + aNewB2DPolygon.append(basegfx::utils::createPolygonFromEllipse(aEllipseCenter,fRadiusX,fRadiusY, 3)); } } rSrcPt += 3; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits