Repository navigation
Open
Labels
tracking-issueAn issue that tracks a larger piece of work.visualizeRelated to the visualize category, which is about drawing and illustrating
Description
Gradient progress report:
- Part 1: Color rework Gradient Part 1 - Color rework #2171
- Part 1a: Color fixes Gradient Part 1a - Color fixes #2262
- Part 2: Linear gradients Gradient Part 2 - Linear gradients #2279
- Part 2a: Sharp gradient fixes Gradient Part 2a - Fix sharp gradients in SVG #2307
- Part 3: Radial gradients Gradient Part 3 - Radial gradients #2312
- Part 4: Conic gradients Gradient Part 4 - Conic gradients #2325
- Part 5a: Gradients on text (
relative: "parent"aka single gradient on all of the text) Part 5a: Gradients on text withrelative: autoorrelative: "parent"#2364 Part 5b: Gradient on text (relative: "self"aka per-glyph gradients)- Part 5b: Fix gradient on math issue Gradient Part 5b: Fix gradients in math #2604 Gradient Part 5c: Fix gradient rotation on text & math #2606
- Part 6: Pattern fills Gradient Part 6 - Pattern fills #2740
- Part 7: Gradient transparency Switch PDF backend to
krilla#5420 - Part 8: Gradient & Pattern AA in rasterized output
- Part 8: Additional gradient features:
- Hue rotation control
- Ability to control linear gradient as a line (start and end point instead of angle)
- Ability to control linear gradient start point
- Ability to deform radial and conical gradient (allowing for elongated shapes)
- Part 9: Gradients along a path (maybe)
The vast majority of those features (all of them in SVG) are available on my gradient branch. However, in this branch the layout engine is completely broken, which I have fixed in these PRs, but didn't bother to on my experimental branch.
The reason why gradients are split up is because part 1 and 2 already account for close to 5000 lines added, the size and complexity of gradients simply balloons when you consider that we support three different export targets, each with their own quirks and limitations that need to be worked around.
This is just a tracking issue I can point to in other gradient PRs ;)
Reacted by Wenzhuo Liu, +merlan #flirora and CGMossa
Reacted by Joseph Alexander Wilson
Metadata
Metadata
Assignees
Labels
tracking-issueAn issue that tracks a larger piece of work.visualizeRelated to the visualize category, which is about drawing and illustrating
Activity
[-]Gradient - Tracking issue[/-][+]🌈 Gradient - Tracking issue[/+]Dherse commentedon Oct 7, 2023
Also closes #443 (with Part 8).
Dherse commentedon Oct 7, 2023
Also closes #260. I'd even go as far as stating that it already closes it.
Dherse commentedon Oct 12, 2023
It was decided in discussion with @laurmaedje that we would not support (at least now) glyph-by-glyph gradients as they're extremely heavy file-size wise, kind of ugly, and difficult to get right.
Starting here on Discord: https://discord.com/channels/1054443721975922748/1088371867913572452/1161943386048188436
stellarpower commentedon Oct 14, 2023
This looks fab! Would building it be as simple as pointing rust to a crate from your fork? Afraid I've not much experience with the language. I would like some gradients in my document, so I can do some basic testing.
laurmaedje commentedon Oct 14, 2023
@stellarpower Most of the gradient work has already landed on main, so if you just compile Typst from main you can just use it.
stellarpower commentedon Oct 14, 2023
Alright, thanks! I will just try building the master branch then.
stellarpower commentedon Oct 15, 2023
As of a596663, it seems that I can fill a box with a gradient (
fillcan take agradient) - but thestrokeforlines doesn't seem to support this; is this worth adding as a subitem above? I imagine single straight lines ought to be a simpler starting point than arbitrary paths or font glyphs, and would enable people to take it for a spin in more situations!Dherse commentedon Oct 15, 2023
@stellarpower With regards to line, they generally you work, you can find an example here but I generally recommend keeping simple linear gradients on line as line technically have a zero width which makes other gradient look... funky?
Truth be told, there is essentially no difference wrt. the "complexity" of the stroke for gradient fills. Currently, gradient fills in parent mode will work on any path you throw at them, it's only when applied in
relative: "self"orrelative: "auto"on lines that it can get tricky.I should also mention that my
gradientbranch has the entire layout engine broken, I strongly advice not to try using it. It just contains the experimental code I have been working on since June/early Julystellarpower commentedon Oct 16, 2023
Okay, so I have to do the
1pt +bit, I presume that turns it from a gradient to a stroke.It seems that fill accepts a gradient or a color, whilst line accepts a color or a stroke (which can be based off a gradient itself), but not a gradient.
Thanks for the advice on your branch, I'll stay clear then.
emilyyyylime commentedon Oct 16, 2023
Also consider
stroke: (paint: gradient(..))laurmaedje commentedon Oct 16, 2023
I think we just need to add the missing gradient -> stroke cast. Seems like an oversight.
laurmaedje commentedon Nov 14, 2023
Should we close this?
Dherse commentedon Nov 14, 2023
I was planning on working on some more features, namely pattern fills in the upcoming weeks just haven't found the motivation just yet
gregzanch commentedon Jan 10, 2025
Should #5647 be included for number 9 on the list? Gradient along a path would technically solve this issue
ibnz36 commentedon May 22, 2025
Hello. what's the state of Part 7? It seems to work on the preview but doesn't when exporting to a PDF.
Code:
Exported:
bugtest.pdf
Dherse commentedon May 22, 2025
@ibnz36 I just updated the tracking issue with the change done in #5420 which added support for transparency gradient in PDF :)
For any bugs please open a dedicated issue if one does not already exist.
ibnz36 commentedon May 22, 2025
@Dherse Should #2546 be reopened?
LaurenzV commentedon May 22, 2025
As mentioned in the issue, the fix doesn't exist in the latest Typst release yet, you need to use the current devevelopment branch if you want the fix.
ibnz36 commentedon May 22, 2025
Oh, I see. Ty