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

Transparent linear gradient rendered incorrectly #594

Open
bdlowery opened this issue Feb 19, 2024 · 6 comments
Open

Transparent linear gradient rendered incorrectly #594

bdlowery opened this issue Feb 19, 2024 · 6 comments

Comments

@bdlowery
Copy link

bdlowery commented Feb 19, 2024

Bug report

Description / Observed Behavior

When using a linear gradient with transparent, it's not actually transparent, it's just black.

Expected Behavior

This css - backgroundImage: 'linear-gradient(transparent, transparent, white)', should render from transparent directly to white. Instead it renders from dark gray to white.

This is the expected behavior: https://codepen.io/bdlowery/pen/dyrrjgW

Reproduction

Reproduction link

@nateeo
Copy link

nateeo commented Feb 29, 2024

Ran into this as well — a workaround like 'linear-gradient(to bottom, #ffffff00, #ffffff00, white)' got me closer to what I wanted.

@natedunn
Copy link

natedunn commented Apr 3, 2024

Ran into this as well — a workaround like 'linear-gradient(to bottom, #ffffff00, #ffffff00, white)' got me closer to what I wanted.

It makes it better but it lightens it up more than ideal.

@gersomvg
Copy link

I thought this wasn't spec, but it is actually spec nowadays: transparent depends on the neighbouring colors in the gradient:

https://www.w3.org/TR/css-images-3/#example-77596609

@bdlowery
Copy link
Author

You can even see in the tabs what the expected behavior should be.

HTML tab shows the expected behavior.

CleanShot 2024-08-20 at 00 08 41
CleanShot 2024-08-20 at 00 08 38

@natedunn
Copy link

natedunn commented Sep 18, 2024

Has anyone found a work around for this?

I find this is also not working for radial-gradient either.

@natedunn
Copy link

Update:

Seems like a tricky issue with how Satori is generating the SVG based on the CSS gradient provided. I'm no SVG expert to know what exactly is causing the issue (inaccurate transformation, rendering issue, or both). You can view the Satori SVG output though, which is helpful for debugging.

I worked around it by constructing my own (simpler) SVG manually and then passing that into Satori itself. 🤙

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

4 participants