Improve dashed arrows
maybe provide a simpler way to create dashed arrows than like that
line((0, 0), (0, 1), stroke: (thickness: .5pt, dash: "dashed"), mark: (end: ">", fill: black, stroke:black))
Intuitive way generates this:
line((0, 0), (0, 1), stroke: (thickness: .5pt, dash: "dashed"), mark: (end: ">"))
This is working as intended. Any style that is auto copies the value of its nearest parent (or at least should in 0.1.2, definitely in 0.2). In this case the mark's stroke is auto so it copies the line's dashed stroke.
If you're using dashed lines a lot you can use set-style:
set-style(mark: (fill: black, stroke: black))
or store the dictionary and use the spreading operator .. to unpack it into the elements you want with the style.
Mark could have a default style like (paint: auto, dash: "solid", ...), which would disable inheriting the dash pattern by default.
I also see why it is implemented as it is @fenjalien, I just noticed that this might be a hustle when drawing images with the library as I did. I used the spreading operator to do something like that:
#let double_arrow = (mark : (end: ">", start: ">"))
#let single_arrow = (mark : (end: ">"))
#let dashed_arrow = (stroke: (dash: "dashed", thickness: .5pt), mark: (stroke: black, end: ">"))
...
and then
line("manager.west", "tcp.east", ..dashed_arrow, name: "manager_tcp")
and I thought this might be a bit verbose and would create problems if I wanted to use a dashed double arrow... Therefore I'd prefere the solution of @johannes-wolf I think this would fix the issue. Is there a simpler way to do this?
There is a style bug in 0.1.2, but something like set-style(mark: (stroke: (dash: "solid", paint: auto))) should work. The problem on 0.1.2 is, that the paint won't get inherited.
If you are using the same color for all your marks it should work though.
#canvas(length: 1cm, {
import draw: *
set-style(line: (mark: (stroke: (dash: "solid", paint: black))))
line((0,0), (5,0), mark: (end: ">"), stroke: (dash: "dotted"))
})
If you are using 0.2.0 the example above should work fine, even if you change the line color.
I think this is solved as we can't reproduce this in 0.2.2, we also don't remember what the problem was or when we fixed it :)