Question about line stroke gradient direction #779
Unanswered
TimeTravelPenguin
asked this question in
Q&A
Replies: 1 comment 2 replies
-
There seems to be a bug with gradient+path in Typst 12.0:
Does setting |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am not entirely sure if this is a Typst feature or something due to Cetz. In my project, I have lines that are coloured as a gradient from, say, red to blue. My algorithm relies on the idea that a line has a source and destination. Hence, I colour my lines based on the parent colour of each destination.
That is, if "from" is red and "to' is blue, then a line connecting "from" and "to" should be a gradient of red to blue.
The issue, however, is that this is not the behaviour that I see. In my project, I have such lines connecting hexagons on a grid. As an example:
This image shows the expected result. Now, when the algorithm draws a "to" that is leftward of the "from" x-coordinate, then the line is effectively "flipped". Instead of drawing from left to right, the line is conceptually rotated about the "from" position, to be a line from right to left. I would expect that a line from coordinate A to B (from "form" and "to") would account for the directionality of the line. The is,
draw.line((0, 0), (1, 1), ...)
is at an angle of 45º. In contrast,draw.line((1, 1), (0, 0), ...)
is drawn at a 225º angle. I would expect that setting the fill of each to the same red-to-blue gradient would show two lines with gradients in the opposite direction. However, this is not what I have experienced. It appears as if the fill doesn't care for the direction of the line.I tried a few different things to mitigate this issue, but the only nice result came from me explicitly making some of the gradients blue-to-red.
I can't add any additional images right now, so I hope this description makes sense. I want to know if this is an intended feature.
If you need additional imagery, please let me know and I will get some up when I hop on my machine in the coming day to two.
Beta Was this translation helpful? Give feedback.
All reactions