Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with cetz #8

Open
mohe2015 opened this issue Oct 31, 2024 · 3 comments
Open

Usage with cetz #8

mohe2015 opened this issue Oct 31, 2024 · 3 comments
Labels
question Further information is requested

Comments

@mohe2015
Copy link

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

@mohe2015
Copy link
Author

Seems like this is trivial with

content(position, pin(pinname))

@OrangeX4
Copy link
Owner

#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.]

@mohe2015
Copy link
Author

mohe2015 commented Oct 31, 2024

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.

@OrangeX4 OrangeX4 added the question Further information is requested label Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants