summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlvin Penner <penner@vaxxine.com>2014-04-30 18:48:20 +0000
committerapenner <penner@vaxxine.com>2014-04-30 18:48:20 +0000
commit399042e2de8699490b9d03d1920ceb4eb53ab37c (patch)
tree442440e62b67d27e634690477cd5f9b29ccc8cb8 /src
parentEnable 'mix-blend-mode' property (rendering only). (diff)
downloadinkscape-399042e2de8699490b9d03d1920ceb4eb53ab37c.tar.gz
inkscape-399042e2de8699490b9d03d1920ceb4eb53ab37c.zip
do not allow ellipse arc segment greater than 90 degrees. (Bug 1312333)
Fixed bugs: - https://launchpad.net/bugs/1312333 (bzr r13327)
Diffstat (limited to 'src')
-rw-r--r--src/sp-ellipse.cpp73
1 files changed, 23 insertions, 50 deletions
diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp
index 25e4c07d7..cda59e057 100644
--- a/src/sp-ellipse.cpp
+++ b/src/sp-ellipse.cpp
@@ -419,62 +419,35 @@ void SPGenericEllipse::set_shape()
// For simplicity, we use a circle with center (0, 0) and radius 1 for our calculations.
Geom::Circle circle(0, 0, 1);
- if (this->_isSlice()) {
- Geom::Point center(0, 0);
- Geom::Point start_point = Geom::Point::polar(start);
- Geom::Point end_point = Geom::Point::polar(end);
- Geom::Point middle_point = make_angle_bisector_ray(Geom::Ray(center, start), Geom::Ray(center, end)).versor();
-
- Geom::EllipticalArc *arc = circle.arc(start_point, middle_point, end_point);
-
- Geom::Path path(start_point);
- path.append(*arc);
-
- delete arc;
-
- Geom::PathBuilder pb;
- pb.append(path);
-
- if (this->_closed) {
- // "pizza slice"
- pb.lineTo(center);
- pb.closePath();
- } else {
- // arc only
- pb.flush();
- }
-
- curve = new SPCurve(pb.peek());
- } else {
- // Full ellipse
- // This code converts the circle to four elliptical arcs explicitly.
- // Circle::getPath currently creates cubic bezier curves, these are not suitable here
- // as a circle should have four mid markers at 0, 90, 180, 270 degrees.
- Geom::Path path(Geom::Point::polar(0));
- Geom::EllipticalArc* arc;
-
- arc = circle.arc(Geom::Point::polar(0), Geom::Point::polar(M_PI / 4.0), Geom::Point::polar(M_PI / 2.0));
- path.append(*arc);
- delete arc;
-
- arc = circle.arc(Geom::Point::polar(M_PI / 2.0), Geom::Point::polar(3.0 * M_PI / 4.0), Geom::Point::polar(M_PI));
- path.append(*arc);
- delete arc;
+ if (!this->_isSlice()) {
+ start = 0.0;
+ end = 2.0*M_PI;
+ }
+ double incr = end - start; // arc angle
+ if (incr < 0.0) incr += 2.0*M_PI;
- arc = circle.arc(Geom::Point::polar(M_PI), Geom::Point::polar(5.0 * M_PI / 4.0), Geom::Point::polar(3.0 * M_PI / 2.0));
- path.append(*arc);
- delete arc;
+ int numsegs = 1 + int(incr*2.0/M_PI); // number of arc segments
+ if (numsegs > 4) numsegs = 4;
- arc = circle.arc(Geom::Point::polar(3.0 * M_PI / 2.0), Geom::Point::polar(7.0 * M_PI / 4.0), Geom::Point::polar(2.0 * M_PI));
+ incr = incr/numsegs; // limit arc angle to less than 90 degrees
+ Geom::Path path(Geom::Point::polar(start));
+ Geom::EllipticalArc* arc;
+ for (int seg = 0; seg < numsegs; seg++) {
+ arc = circle.arc(Geom::Point::polar(start + seg*incr), Geom::Point::polar(start + (seg + 0.5)*incr), Geom::Point::polar(start + (seg + 1.0)*incr));
path.append(*arc);
delete arc;
-
- Geom::PathBuilder pb;
- pb.append(path);
+ }
+ Geom::PathBuilder pb;
+ pb.append(path);
+ if (this->_isSlice() && this->_closed) {
+ pb.lineTo(Geom::Point(0, 0));
+ }
+ if (this->_closed) {
pb.closePath();
-
- curve = new SPCurve(pb.peek());
+ } else {
+ pb.flush();
}
+ curve = new SPCurve(pb.peek());
// gchar *str = sp_svg_write_path(curve->get_pathvector());
// std::cout << " path: " << str << std::endl;