Add triangle shape
moritzketzer opened this issue · 2 comments
moritzketzer commented
I need a triangle shape for my diagrams, but I don't have the time to learn cetz and fletcher to add it myself (I tried, but it was not possible to label the node).
Could you add a triangle shape or show me how I can define a triangle shape myself according to the rules that fletcher accepts? That would be much appreciated!
Jollywatt commented
#import "@preview/fletcher:0.4.4": diagram, node, edge, cetz
#let triangle(node, extrude) = {
let (w, h) = node.size
w += 2*extrude
h += 2*extrude
cetz.draw.line(
(-w, -h/2),
(+w, -h/2),
(0, +h),
close: true
)
}
#diagram(
node-stroke: 1pt,
node-outset: 3pt,
node((0,0), [Hello,\ World!], shape: triangle),
edge("->"),
node((1,1), $a b c$, shape: triangle, extrude: (0, -2))
)
The only trick here is how the extrude
distance is added to the node size, to support node extrude
and outset
moritzketzer commented
Thank you so much! :)