You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Path stroke gradients do not work as expected #5647
Tested with typst 0.12.0 (dhb06dbf9). On current master, drawing gradient strokes with path got fixed (with the new curve API): it is possible to stroke straight lines (angle 0deg) with a gradient now. But drawing the line flipped, does not flip the gradient (in contrast to line).
With line, the gradient gets reversed, if the end: is left of start:. Not sure if this is really a bug, or expected behaviour.
The following code:
#letred-blue= gradient.linear(red, blue, relative: "self")
// Ok#path((0cm, 0cm), (5cm, 0cm), stroke: red-blue+5pt)
// Expected blue to red gradient, got red to blue#path((5cm, 0cm), (0cm, 0cm), stroke: red-blue+5pt)
I think the a potential issue here is that the gradient is defined (which includes the angle of the gradient) and then the paths use the absolute angle of the gradient rather than relative to path definition.
This may be a non issue but I'll still look into it.
Gradient along a path are likely among the hardest to support. In theory, you could create (in PDF) a function that goes from 0 to 1 and then interpolate at several points along the path to get it working nicely, but it's tricky.
Gradient along a path are likely among the hardest to support. In theory, you could create (in PDF) a function that goes from 0 to 1 and then interpolate at several points along the path to get it working nicely, but it's tricky.
Could it be a worth while feature to consider? I'm not fully versed on the architecture, but maybe there could be a parameter/stroke type that enables a gradient as described above.
The gradient could be called something of the sort "perpendicular-path-gradient". This gradient would interpolate the full path length from 0-1, and then add sub gradients at each path vertex which aligns to the users specification.
This is something way out of scope here, but maybe could be a feature in the future?
For a solution here, we could write documentation that shows how gradients behave relative to path "orientation".
I think it would be a worthwhile feature to have. Just a fairly difficult one to implement. The problem is that doing "per-vertex" gradients would be a huge nono (file size) so you'd need to re-use one gradient (which is definitely doable of course).
Activity
gregzanch commentedon Jan 10, 2025
I'd like to take a stab at this!
I think the a potential issue here is that the gradient is defined (which includes the angle of the gradient) and then the paths use the absolute angle of the gradient rather than relative to path definition.
This may be a non issue but I'll still look into it.
Dherse commentedon Jan 10, 2025
Gradient along a path are likely among the hardest to support. In theory, you could create (in PDF) a function that goes from 0 to 1 and then interpolate at several points along the path to get it working nicely, but it's tricky.
gregzanch commentedon Jan 11, 2025
Could it be a worth while feature to consider? I'm not fully versed on the architecture, but maybe there could be a parameter/stroke type that enables a gradient as described above.
The gradient could be called something of the sort "perpendicular-path-gradient". This gradient would interpolate the full path length from 0-1, and then add sub gradients at each path vertex which aligns to the users specification.
This is something way out of scope here, but maybe could be a feature in the future?
For a solution here, we could write documentation that shows how gradients behave relative to path "orientation".
Dherse commentedon Jan 11, 2025
I think it would be a worthwhile feature to have. Just a fairly difficult one to implement. The problem is that doing "per-vertex" gradients would be a huge nono (file size) so you'd need to re-use one gradient (which is definitely doable of course).