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

Cubic Bezier Segment not matching SVG? #880

Closed
mattzque opened this issue Oct 30, 2023 · 1 comment
Closed

Cubic Bezier Segment not matching SVG? #880

mattzque opened this issue Oct 30, 2023 · 1 comment

Comments

@mattzque
Copy link

I'm probably just doing something wrong, but if I make a SVG like this:

<svg width="100" height="100">
  <path d="M 0 0 C 0 0, 50 100, 100 0" stroke="black" fill="transparent" />
</svg>

20231030022734

(y down in svg) and I try to do the same thing in lyon:

        let lyon_segment = CubicBezierSegment {
            from: Point::new(0.0, 0.0),
            ctrl1: Point::new(0.0, 0.0),
            ctrl2: Point::new(50.0, 100.0),
            to: Point::new(100.0, 0.0),
        };
        for t in 0..=100 {
            let t = t as f32 / 100.0;
            let y = lyon_segment.sample(t).y;
            println!("t: {:?} -> {:?}", t, y);
        }

I get this: (y up)

20231030023300

what am I doing wrong?

@mattzque
Copy link
Author

mattzque commented Oct 30, 2023

nevermind I figured it out! all good (i was using t wrong, t doesnt equal x here)

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

1 participant