Commit 69351245 authored by RazrFalcon's avatar RazrFalcon

Fixed 'offset' attribute resolving inside the 'stop' element.

parent e6efe102
e-filter-057.svg
e-linearGradient-006.svg
e-linearGradient-029.svg
e-linearGradient-031.svg
e-pattern-027.svg
e-radialGradient-006.svg
e-radialGradient-039.svg
e-stop-028.svg
e-filter-057.svg
e-linearGradient-006.svg
e-linearGradient-029.svg
e-linearGradient-031.svg
e-pattern-027.svg
e-radialGradient-006.svg
e-radialGradient-039.svg
e-stop-028.svg
......@@ -81,6 +81,35 @@ fn _fix_gradient_stops(grad: &Node, stops: &mut Vec<Node>, doc: &mut Document) {
}
}
// Remove zeros.
//
// From:
// offset="0.0"
// offset="0.0"
// offset="0.7"
//
// To:
// offset="0.0"
// offset="0.00000001"
// offset="0.7"
{
stops.clear();
for stop in grad.children() {
stops.push(stop);
}
while stops.len() >= 2 {
let offset1 = stops[0].attributes().get_number_or(AId::Offset, 0.0);
let offset2 = stops[1].attributes().get_number_or(AId::Offset, 0.0);
if offset1.is_fuzzy_zero() && offset2.is_fuzzy_zero() {
stops[1].set_attribute((AId::Offset, offset1 + f64::EPSILON));
} else {
break;
}
}
}
// Shift equal offsets.
//
// From:
......@@ -97,11 +126,6 @@ fn _fix_gradient_stops(grad: &Node, stops: &mut Vec<Node>, doc: &mut Document) {
for mut stop in grad.children() {
let mut offset = stop.attributes().get_number_or(AId::Offset, 0.0);
if offset.is_fuzzy_zero() {
prev_offset = 0.0;
continue;
}
// Next offset must be smaller then previous.
if offset < prev_offset || offset.fuzzy_eq(&prev_offset) {
if let Some(mut prev_stop) = stop.previous_sibling() {
......@@ -117,33 +141,4 @@ fn _fix_gradient_stops(grad: &Node, stops: &mut Vec<Node>, doc: &mut Document) {
prev_offset = offset;
}
}
// Remove zeros.
//
// From:
// offset="0.0"
// offset="0.0"
// offset="0.7"
//
// To:
// offset="0.0"
// offset="0.00000001"
// offset="0.7"
{
stops.clear();
for stop in grad.children() {
stops.push(stop);
}
while stops.len() >= 2 {
let offset1 = stops[0].attributes().get_number_or(AId::Offset, 0.0);
let offset2 = stops[1].attributes().get_number_or(AId::Offset, 0.0);
if offset1.is_fuzzy_zero() && offset2.is_fuzzy_zero() {
stops[1].set_attribute((AId::Offset, offset1 + f64::EPSILON));
} else {
break;
}
}
}
}
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