(#372): Fix mis-rendering in small arc segments

The code was checking for division by 0.0 a bit too aggressively.  For
small radiuses (say, 0.25 units), this gives intermediate results that
are perfectly (and exactly!) representable within f64, but the code
was checking for 0 too coarsely.

Regenerated the test reference files for Adwaita that got minor
rendering changes because of this.

#372
parent 6e4cad65
......@@ -135,7 +135,7 @@ impl EllipticalArc {
// Compute the transformed center (cx', cy').
let d = (rx * y1_).powi(2) + (ry * x1_).powi(2);
if d.approx_eq_cairo(&0.0) {
if d == 0.0 {
return ArcParameterization::Omit;
}
let k = {
......@@ -156,7 +156,7 @@ impl EllipticalArc {
let ux = (x1_ - cx_) / rx;
let uy = (y1_ - cy_) / ry;
let u_len = (ux * ux + uy * uy).abs().sqrt();
if u_len.approx_eq_cairo(&0.0) {
if u_len == 0.0 {
return ArcParameterization::Omit;
}
let cos_theta1 = clamp(ux / u_len, -1.0, 1.0);
......@@ -172,7 +172,7 @@ impl EllipticalArc {
let vx = (-x1_ - cx_) / rx;
let vy = (-y1_ - cy_) / ry;
let v_len = (vx * vx + vy * vy).abs().sqrt();
if v_len.approx_eq_cairo(&0.0) {
if v_len == 0.0 {
return ArcParameterization::Omit;
}
let dp_uv = ux * vx + uy * vy;
......
<svg xmlns="http://www.w3.org/2000/svg" width="320" height="320" viewBox="0 0 16 16">
<path d="M 4.25 4
h .5
a .25 .25 0 0 1 .25 .25
V 5
h .75
a .25 .25 0 0 1 .25 .25
v .5
a .25 .25 0 0 1 -.25 .25
H 5
v .75
a .25 .25 0 0 1 -.25 .25
h -.5
A .25 .25 0 0 1 4 6.75
V 6
h -.75
A .25 .25 0 0 1 3 5.75
v -.5
A .25 .25 0 0 1 3.25 5
H 4
v -.75
A .25 .25 0 0 1 4.25 4
z"/>
</svg>
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