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

feat: support repeating-linear-gradient #630

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

Jackie1210
Copy link
Contributor

Now that #624 has been merged, let me bringrepeating-linear-gradient to satori~ ❤️

Close #554

Note about the algorithm:


Option 1: 0 < deg < 90

define

$$r=(h/w)^2$$

then, calculate the intersection point of the last two lines

$$y = - r / tan(angle) ·x + w / 2 + h/2+r·w/ (2·tan(angle))$$ $$y=tan(angle) ·x + h$$

Finally, we can get (x1, y1), (x2, y2)

about length:

$$y = - 1 / tan(angle) ·x + w / 2 + h/2+r·w/ (2·tan(angle))$$ $$y=tan(angle) ·x + h$$

then, we can get a point: (a, b), so length is $2 ·\sqrt{(a - w/2)^2 + (b - h/2)^2}$


Option 2: 90 < deg < 180

define

$$r=(h/w)^2$$

then, calculate the intersection point of the last two lines

$$y = - r / tan(angle) ·x + w / 2 + h/2+r·w/ (2·tan(angle))$$ $$y=tan(angle) ·x$$

Finally, we can get (x1, y1), (x2, y2)

about length:

$$y = - 1 / tan(angle) ·x + w / 2 + h/2+r·w/ (2·tan(angle))$$ $$y=tan(angle) ·x$$

then, we can get a point: (a, b), so length is $2 ·\sqrt{(a - w/2)^2 + (b - h/2)^2}$

Actually, I didn't find any spec of the algorithm on calculating the points. I just came across the algorithm accidentally. It turns out it shows the same result just like chrome renders.

@Jackie1210 Jackie1210 requested a review from shuding as a code owner July 4, 2024 14:40
Copy link

vercel bot commented Jul 4, 2024

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

Name Status Preview Comments Updated (UTC)
satori-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 4, 2024 2:40pm

Copy link
Member

@shuding shuding left a comment

Choose a reason for hiding this comment

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

This is incredible! Thank you!

@shuding shuding merged commit ff80448 into vercel:main Sep 14, 2024
9 checks passed
Copy link

🎉 This PR is included in version 0.11.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

repeating-linear-gradient() is not working when rendered as png, svg or pdf
2 participants