Kaydet (Commit) c4c1636b authored tarafından Regina Henschel's avatar Regina Henschel

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: 's avatarRegina Henschel <rb.henschel@t-online.de>
üst 90b93b69
......@@ -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);
......
......@@ -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
*/
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment