diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2018-11-14 14:30:49 +0100 |
---|---|---|
committer | Regina Henschel <rb.henschel@t-online.de> | 2018-11-16 17:45:48 +0100 |
commit | c4c1636b5132261e64492de38f252b19b77e69b8 (patch) | |
tree | 01ac0188baf7601d770431aa48ebf164697f92d4 /svx/source/customshapes | |
parent | 90b93b6964e922fcc4aaadf06278edc0e10af925 (diff) |
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.henschel@t-online.de>
Diffstat (limited to 'svx/source/customshapes')
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShape2d.cxx | 40 |
1 files changed, 5 insertions, 35 deletions
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; |