typst-pinit
typst-pinit copied to clipboard
Usage with cetz
Hi,
is it somehow possible to point to something in a cetz canvas? By reading the documentation I could not find out how/whether this works.
Thank you
Kind regards Moritz
Seems like this is trivial with
content(position, pin(pinname))
#import "@preview/cetz:0.3.1": canvas, draw, tree
#import "@preview/pinit:0.2.2": *
#let data = (
[A], ([B], [C], [D]), ([E], [F#pin(1)])
)
#canvas(length: 1cm, {
import draw: *
set-style(content: (padding: .2),
fill: gray.lighten(70%),
stroke: gray.lighten(70%))
tree.tree(data, spread: 2.5, grow: 1.5, draw-node: (node, ..) => {
circle((), radius: .45, stroke: none)
content((), node.content)
}, draw-edge: (from, to, ..) => {
line((a: from, number: .6, b: to),
(a: to, number: .6, b: from), mark: (end: ">"))
}, name: "tree")
// Draw a "custom" connection between two nodes
let (a, b) = ("tree.0-0-1", "tree.0-1-0",)
line((a, .6, b), (b, .6, a), mark: (end: ">", start: ">"))
})
#pinit-point-from(1)[It is simple.]
Thank you very much for the quick response and this library. Maybe you want to add this example to the README? After the fact this is pretty obvious but I still didn't get this idea directly.