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

fix: Backtracking now doesn't create dots at end of lines #54

Merged
merged 1 commit into from
Aug 22, 2022

Conversation

TodePond
Copy link
Contributor

See: #48

This fixes a bug where sharp corners would sometimes cause a "dot" to appear at the end of a line. The bug happened because some sharp corners were not getting detected. To detect them, I made it also check the dot-product of the current point and previous point (not just the next point). Maybe a cleaner fix here, but maybe it can solve it for now.

Line 212 and 213 could be better - I made them kinda messy to avoid typescript complaining but there's probably a better way of structuring it?

@vercel
Copy link

vercel bot commented Aug 22, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
perfect-freehand-example ✅ Ready (Inspect) Visit Preview Aug 22, 2022 at 3:17PM (UTC)
pf-dev ✅ Ready (Inspect) Visit Preview Aug 22, 2022 at 3:17PM (UTC)

@steveruizok
Copy link
Owner

Works for me!

@steveruizok steveruizok merged commit cabf524 into steveruizok:main Aug 22, 2022
if (nextDpr < 0) {
const nextVector = (i < points.length - 1? points[i + 1] : points[i]).vector
const nextDpr = (i < points.length - 1? dpr(vector, nextVector) : 1.0)
const prevDpr = dpr(vector, prevVector)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is prevDpr always equal to last iteration's nextDpr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe! I'll check. Definitely a cleaner fix in here somewhere

Copy link
Contributor Author

@TodePond TodePond Aug 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so yes, they are usually the same (apart from some occasional float imprecision)
image

Except for very rare cases:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's another example that's not from the final two iterations:

image

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

Successfully merging this pull request may close these issues.

2 participants