Skip to content

Conversation

@SArpnt
Copy link

@SArpnt SArpnt commented Mar 5, 2025

this fixes blur in firefox (especially on text), gives the regular snap style much more accurate block borders and text shadow, and removes quite a bit of bad code.

there's several unrelated changes in these commits so feel free to cherry pick if one of the commits is real bad

before:
image
snap:
image
after:
image

@ego-lay-atman-bay
Copy link
Collaborator

ego-lay-atman-bay commented Mar 6, 2025

After testing it out, I can see that it's now worse in chrome.
image

However it does look better in firefox
image

When I zoom in on both chrome and firefox, they do look the same, so it's just a matter of how each engine scales svgs. I'm not going to merge this right now, since it does give a worse look on chrome now.

Perhaps the better thing to do about the bevels is actually changing them to how snap draws them, as paths with a linear gradient. Sure, it'll bloat the svgs even more, but it might make it work better on both browser engines.

@SArpnt
Copy link
Author

SArpnt commented Mar 6, 2025

hm, i was testing changes on chrome when starting out but assumed the later changes would be fine. it's all out of order now after all the rebasing. i should still be able to make chrome match firefox with some small tweaks.

SArpnt added 5 commits March 5, 2025 19:25
fits in better with snap block changes in later commits
fits in better with snap block changes in later commits
shadow edges aren't clipped twice.
i don't think the old filter would blur in firefox but the general method used usually would.
this new method uses patterns that shouldn't have that happen.

this fits in better with snap block changes in later commits.
…scale

previously filter bounds and particular effects (mostly feFlood)
would cause some problems with element dimensions in firefox and make
that element blurry and incorrectly positioned. many filters also
had coordinates rounded differently between the browsers.

this new svg filter act the same between browsers and
is nicer and simpler in several ways
@SArpnt
Copy link
Author

SArpnt commented Mar 6, 2025

it looks almost exactly the same in both browsers to me?

firefox 100% zoom:
image
chrome 100% zoom:
image
firefox 200% zoom:
image
chrome 200% zoom:
image

chrome has a harder border at 100% zoom and the fat borders at larger zooms isn't great (i probably turned the blur down too low), but i'm not getting what you have at all.
you implied that what you're getting now is when it isn't zoomed in. do you have a high dpi screen? if that's changing how it scales i don't know how i can test for that.

SArpnt added 2 commits March 5, 2025 20:12
similar to the previous commit, the block bevel caused blur and misalignment in firefox.
this new filter is also more accurate in general due to other tweaks.
it looks slightly different between browsers but it's close enough.
they contain serious bugs, make inefficient output, usually cause blur on firefox,
and aren't much more ergonomic than writing out the filter manually.
@SArpnt
Copy link
Author

SArpnt commented Mar 6, 2025

i adjusted the bevel edges to add a slight bit more blur for when zoomed in (i don't think i can get away with more without messing up normal sizes) and reordered the commits from least to most invasive changes.

you should be able to pull up to the blurry text fix for now if the bevel edges are still an issue. i think the text change is the most important fix out of the set.

@ego-lay-atman-bay
Copy link
Collaborator

ego-lay-atman-bay commented Mar 6, 2025

It might be a DPI thing, since I have my display scale set to 125%. When I change it to 100% chrome looks the same as firefox. Also, it still looks the same as it did before (or at least, I currently don't see any changes).

100% Display scale:
Chrome 100% zoom:
image

Firefox 100% zoom:
image

Chrome 200% zoom:
image

Firefox 200% zoom:
image

125% Display scale:
Chrome 100% zoom:
image

Firefox 100% zoom:
image

Chrome 200% zoom:
image

Firefox 200% zoom:
image

@SArpnt
Copy link
Author

SArpnt commented Mar 6, 2025

i only made a very subtle change to the block's lighting. there's really not a lot of room for adjustment.

maybe a convolution matrix could shift the text over by a physical pixel more reliably? it would probably be much simpler to just generate more svg nodes. give the text an id and <use> it for the shadow. i don't think more work on the svg filters is worth it.

if/when you go down the route of making thousands of similar paths i'd recommend you just put each block once in <defs> and then reuse them as border images. i haven't checked if svg widely supports border images but if not you can simulate it manually with many <use>s and transforms. i've been using border images to render blocks with dead simple html for my own wip project.

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