Skip to content
New issue

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

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

Already on GitHub? # to your account

wip: clip pipes to tile polygons #101

Closed

Conversation

gordonwoodhull
Copy link
Contributor

This is a work-in-progress fix for #91 rendering glitches on iOS.

iOS does not draw line ends correctly for the purpose of drawing pipes, never mind when stroke-linejoin and/or transformations are involved.

There were some proposed extensions to SVG to fix all this, but the advice I have read is that you can do most of what you want to do with clipPath.

So here is a first attempt. We generate the clip polygon the same as the tile path, except without subtracting border_width from the radius. Right now it is also adding half a border width to the radius because I was still seeing 1px of grey on iOS without it.

We also extend the pipes by 1.2 - probably more than needed, but we need a little stretch because iOS does not always draw all the way.

Before/after 📷 🧵

this addresses gereleth#91 but it has its own glitches
@vercel
Copy link

vercel bot commented Aug 12, 2023

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

Name Status Preview Comments Updated (UTC)
hexapipes ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 12, 2023 5:27am

@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Aug 12, 2023

Etrat before / after on Firefox iOS
image0
image1

There is still a very thin hairline edge drawn, especially on diagonals; sometimes it looks looks like an anti-aliasing glitch and sometimes (as here) it looks like there is still 1px and might benefit from greater radius.

@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Aug 12, 2023

Cube grid before

IMG_7978

After it's a little bit off, but much better than it was.
IMG_7979

@gordonwoodhull
Copy link
Contributor Author

Rendering is almost flawless in Firefox on Android, seems to have anti-aliasing edge though.
img1
img1

@gordonwoodhull
Copy link
Contributor Author

Needless to say, I'm looking at this because I think it could help with uniform pipe widths for penrose. But it would be great to fix the iOS rendering issues too.

@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Aug 12, 2023

Again almost flawless on Firefox/macOS, just the thinnest hair:
macOS edges

All displays are high-resolution; I haven't tested this in low res yet.

@gordonwoodhull
Copy link
Contributor Author

Since the clip paths are relative to the tile coordinate, we don't really need one clipPath for every tile.

An easy way to share them is just to memoize the clip paths. It would be nicer for debugging if the grid labeled them so that the ids are meaningful.

not just visible
also make clip path ids unique across all svgs
because they share the page's namespace
@gordonwoodhull
Copy link
Contributor Author

Not sure why in opened a PR for this so early, guess I was just excited that it worked.

Next week maybe I'll try putting it under a flag so it can be active only for iOS and for grids that need it.

Personally I prefer the hairline to the smudge but that's just my opinion.

@gordonwoodhull
Copy link
Contributor Author

I'm closing this because it needs a lot more work, as described above. Hope to return to this later.

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

Successfully merging this pull request may close these issues.

1 participant