Skip to content

Gradient Part 3 - Radial gradients - #2312

Merged
laurmaedje merged 20 commits into
typst:mainfrom
Dherse:gradient-radial
Oct 6, 2023
Merged

laurmaedje merged 20 commits into
typst:mainfrom
Dherse:gradient-radial

Conversation

@Dherse

@Dherse Dherse commented Oct 4, 2023

Copy link
Copy Markdown
Contributor

Tracking issue #2282

Building onto #2307 this PR adds fully featured radial gradients inspired (like other gradients) by the CSS API.

It is simple to use using gradient.radial(..stops) or you can set some parameters like the radius and center, or the focal radius and focal center. It can create simple 3D effects like can be seen below. It is compatible with the full feature set that was previously described, I added relevant tests. It works flawlessly in all three export targets.

Some examples:

image

image

@Dherse Dherse mentioned this pull request Oct 4, 2023
11 of 13 tasks
@Dherse
Dherse marked this pull request as draft October 4, 2023 22:43
@Dherse

Dherse commented Oct 4, 2023

Copy link
Copy Markdown
Contributor Author

@Enivex tried working on an improved algorithm for PNG export but it has two issues:

  • It suffers in some edge cases
  • It suffers from platform dependance for float computations which leads to failing CI :(

@Dherse
Dherse marked this pull request as ready for review October 4, 2023 22:55
@Dherse
Dherse marked this pull request as draft October 5, 2023 07:59
@Dherse
Dherse marked this pull request as ready for review October 6, 2023 14:27
@Dherse

Dherse commented Oct 6, 2023 •

Copy link
Copy Markdown
Contributor Author

Thanks to @Enivex for the improved PNG export math, and thanks to @RazrFalcon for pointing out the flaw in the stroke edge-cases I was trying to fix in the linebender/tiny-skia#107 :)

@laurmaedje
laurmaedje merged commit e7443ab into typst:main Oct 6, 2023
@laurmaedje

Copy link
Copy Markdown
Member

Thank you!

@Dherse
Dherse deleted the gradient-radial branch October 6, 2023 14:48
Dikluwe pushed a commit to Dikluwe/typst-crystalline that referenced this pull request Sep 12, 2026
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