[librsvg/rustification] bgo#763386: Handle missing case of coincident control points
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/rustification] bgo#763386: Handle missing case of coincident control points
- Date: Wed, 14 Dec 2016 19:33:47 +0000 (UTC)
commit 7714dfe8aa6836ab59f78cdd7eb00a814897e21e
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Dec 14 13:27:05 2016 -0600
bgo#763386: Handle missing case of coincident control points
... are we done with these yet?
Thanks again to Massimo for pointing out this case in
https://bugzilla.gnome.org/show_bug.cgi?id=763386#c4
rust/src/marker.rs | 42 +++++++++++++++++--
.../reftests/bugs/763386-marker-coincident-ref.png | Bin 943 -> 1198 bytes
.../reftests/bugs/763386-marker-coincident.svg | 4 +-
3 files changed, 40 insertions(+), 6 deletions(-)
---
diff --git a/rust/src/marker.rs b/rust/src/marker.rs
index 665680f..f0067ad 100644
--- a/rust/src/marker.rs
+++ b/rust/src/marker.rs
@@ -193,18 +193,41 @@ fn get_segment_directionalities (segment: &Segment) -> Option <(f64, f64, f64, f
Segment::Degenerate { .. } => { None },
Segment::LineOrCurve { x1, y1, x2, y2, x3, y3, x4, y4 } => {
- if points_equal (x1, y1, x2, y2) && points_equal (x1, y1, x3, y3) && points_equal (x1, y1, x4,
y4) {
+ let coincide_1_and_2 = points_equal (x1, y1, x2, y2);
+ let coincide_1_and_3 = points_equal (x1, y1, x3, y3);
+ let coincide_1_and_4 = points_equal (x1, y1, x4, y4);
+ let coincide_2_and_3 = points_equal (x2, y2, x3, y3);
+ let coincide_2_and_4 = points_equal (x2, y2, x4, y4);
+ let coincide_3_and_4 = points_equal (x3, y3, x4, y4);
+
+ if coincide_1_and_2 && coincide_1_and_3 && coincide_1_and_4 {
+
None
- } else if points_equal (x1, y1, x2, y2) && points_equal (x1, y1, x3, y3) {
+
+ } else if coincide_1_and_2 && coincide_1_and_3 {
+
Some ((x4 - x1, y4 - y1, x4 - x3, y4 - y3))
- } else if points_equal (x2, y2, x3, y3) && points_equal (x2, y2, x4, y4) {
+
+ } else if coincide_1_and_2 && coincide_3_and_4 {
+
+ Some ((x4 - x1, y4 - y1, x4 - x1, y4 - y1))
+
+ } else if coincide_2_and_3 && coincide_2_and_4 {
+
Some ((x2 - x1, y2 - y1, x4 - x1, y4 - y1))
- } else if points_equal (x1, y1, x2, y2) {
+
+ } else if coincide_1_and_2 {
+
Some ((x3 - x1, y3 - y1, x4 - x3, y4 - y3))
- } else if points_equal (x3, y3, x4, y4) {
+
+ } else if coincide_3_and_4 {
+
Some ((x2 - x1, y2 - y1, x4 - x2, y4 - y2))
+
} else {
+
Some ((x2 - x1, y2 - y1, x4 - x3, y4 - y3))
+
}
}
}
@@ -728,4 +751,13 @@ mod tests {
assert_eq! ((-20.0, -40.0), (v1x, v1y));
assert_eq! ((-20.0, -40.0), (v2x, v2y));
}
+
+ #[test]
+ fn curve_with_12_34_coincident_has_directionality () {
+ let (v1x, v1y, v2x, v2y) =
+ super::get_segment_directionalities (&curve (20.0, 40.0, 20.0, 40.0, 60.0, 70.0, 60.0,
70.0)).unwrap ();
+
+ assert_eq! ((40.0, 30.0), (v1x, v1y));
+ assert_eq! ((40.0, 30.0), (v2x, v2y));
+ }
}
diff --git a/tests/fixtures/reftests/bugs/763386-marker-coincident-ref.png
b/tests/fixtures/reftests/bugs/763386-marker-coincident-ref.png
index 09e8852..2248fd7 100644
Binary files a/tests/fixtures/reftests/bugs/763386-marker-coincident-ref.png and
b/tests/fixtures/reftests/bugs/763386-marker-coincident-ref.png differ
diff --git a/tests/fixtures/reftests/bugs/763386-marker-coincident.svg
b/tests/fixtures/reftests/bugs/763386-marker-coincident.svg
index 6829102..7af4f9e 100644
--- a/tests/fixtures/reftests/bugs/763386-marker-coincident.svg
+++ b/tests/fixtures/reftests/bugs/763386-marker-coincident.svg
@@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
- viewBox="0 0 130 64">
+ viewBox="0 0 130 130">
<marker id="marker"
viewBox="-4 -4 8 8"
orient="auto">
@@ -10,4 +10,6 @@
stroke="red" d="M 12,12 c 0,0 0,0 40,40"/>
<path stroke-width="8" marker-start="url(#marker)" marker-end="url(#marker)"
stroke="red" d="M 118,12 c -40,40 -40,40 -40,40"/>
+ <path stroke-width="8" marker-start="url(#marker)" marker-end="url(#marker)"
+ stroke="red" d="M 12,70 c 0,0 40,40 40,40"/>
</svg>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]