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

[Question] Walk BezierPath evenly obtaining positions and tangents #27

Open
zdila opened this issue Feb 14, 2024 · 2 comments
Open

[Question] Walk BezierPath evenly obtaining positions and tangents #27

zdila opened this issue Feb 14, 2024 · 2 comments

Comments

@zdila
Copy link

zdila commented Feb 14, 2024

I am looking for a way to walk BezierPath evenly to get points and their tangents. I also need to specify initial offset (space). What would be a good approach for this?

@Logicalshift
Copy link
Owner

There's a function for this: walk_curve_evenly(). The EvenWalkIterator it returns has a vary_by() function that can be used to change the size of the following steps, so that can be used to skip a part at the start of the curve.

This function works using chord lengths (distance between points on the curve rather than the length of the curve itself), however, so it can lose accuracy if the steps are very large or at points where the curvature is very high. An uneven walk of the curve will return more dense points where the curvature is higher, so could be used to mitigate this.

v0.8 of flo_curves adds a flatness() function that can be used to subdivide curves into approximately straight line segments, which would further mitigate this problem (though I haven't added much yet to the library to use this for specific problems like this)

@zdila
Copy link
Author

zdila commented Feb 27, 2024

Thank you. I actually ended with copy_path_flat as I am using Cairo-rs.

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