Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arc() does infinite loop on NaN or inf #177

Open
Swrup opened this issue Aug 31, 2021 · 2 comments
Open

arc() does infinite loop on NaN or inf #177

Swrup opened this issue Aug 31, 2021 · 2 comments

Comments

@Swrup
Copy link

Swrup commented Aug 31, 2021

Hello,

If start_angle or sweep_angle are NaN or inf, arc() will make stroke() fall into an infinite loop.
Maybe arc() should panic instead?

@jrmuizel
Copy link
Owner

What was the situation where you ran into this?

@Swrup
Copy link
Author

Swrup commented Sep 1, 2021

Here is the code
Notice that in StrokeStyle dash_offset was set to 1.
It seems it only happens if I change the StrokeStyle.

use raqote::*;

fn main() {
    let mut dt = DrawTarget::new(400, 400);

    let mut pb = PathBuilder::new();
    pb.arc(100., 100., 10., 1. / 0., 2.);
    let path = pb.finish();

    dt.stroke(
        &path,
        &Source::Solid(SolidSource {
            r: 0x0,
            g: 0x0,
            b: 0x80,
            a: 0x80,
        }),
        &StrokeStyle {
            cap: LineCap::Round,
            join: LineJoin::Round,
            width: 10.,
            miter_limit: 2.,
            dash_array: vec![10., 18.],
            dash_offset: 1.,
        },
        &DrawOptions::new(),
    );

    println!("{:?}", dt.write_png("example.png"));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants