Commit aa53f045 authored by Federico Mena Quintero's avatar Federico Mena Quintero

Merge branch 'small-arc-segments' into 'master'

Small arc segments

Closes #372

See merge request GNOME/librsvg!145
parents 858a09a4 e47dd173
Pipeline #39074 failed with stages
in 22 minutes and 33 seconds
......@@ -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;
......
......@@ -123,14 +123,25 @@ impl NodePath {
}
impl NodeTrait for NodePath {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag<'_>) -> NodeResult {
fn set_atts(
&self,
node: &RsvgNode,
_: *const RsvgHandle,
pbag: &PropertyBag<'_>,
) -> NodeResult {
for (_key, attr, value) in pbag.iter() {
if attr == Attribute::D {
let mut builder = PathBuilder::new();
if path_parser::parse_path_into_builder(value, &mut builder).is_err() {
if let Err(e) = path_parser::parse_path_into_builder(value, &mut builder) {
// FIXME: we don't propagate errors upstream, but creating a partial
// path is OK per the spec
rsvg_log!(
"could not parse path {}: {}",
node.get_human_readable_name(),
e
);
}
*self.builder.borrow_mut() = Some(builder);
......
<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