diff options
-rw-r--r-- | basegfx/source/polygon/b2dpolygontools.cxx | 4 | ||||
-rw-r--r-- | include/basegfx/polygon/b2dpolygontools.hxx | 9 | ||||
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShape2d.cxx | 40 |
3 files changed, 13 insertions, 40 deletions
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; |