Skip to content
\n

\"image\"

","upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"

I guess you want something dynamic like the following:

\n
#import \"@preview/cetz:0.2.2\"\n#set page(width: auto, height: auto)\n\n#cetz.canvas({\n  import cetz.draw: *\n\n  set-style(circle: (radius: 0.8em))\n  circle((0,0), name: \"circ1\")\n  circle((2,2), name: \"circ2\")\n\n  \n  line(\"circ1\",                             /* Intersection of a straight line between circ1.center and the next coordinate */\n       ((), \"-|\", (\"circ1\", 50%, \"circ2\")), /* Move only horizontal to (circ1.x + circ2.x)/2 */\n       ((), \"|-\", \"circ2\"),                 /* Move vertically to circ2.y */\n       \"circ2\",                             /* Same as 1. but for circ2 */\n      mark: (start: \">\", fill: black))\n})
\n

With \"circ2\" at (2,2):
\n\"grafik\"

\n

With \"circ2\" at (-3,1):
\n\"grafik\"

","upvoteCount":2,"url":"https://github.com/cetz-package/cetz/discussions/678#discussioncomment-10296564"}}}

Automatic adjustment of coordinates #678

Answered by johannes-wolf
psads-git asked this question in Q&A
Discussion options

You must be logged in to vote

I guess you want something dynamic like the following:

#import "@preview/cetz:0.2.2"
#set page(width: auto, height: auto)

#cetz.canvas({
  import cetz.draw: *

  set-style(circle: (radius: 0.8em))
  circle((0,0), name: "circ1")
  circle((2,2), name: "circ2")

  
  line("circ1",                             /* Intersection of a straight line between circ1.center and the next coordinate */
       ((), "-|", ("circ1", 50%, "circ2")), /* Move only horizontal to (circ1.x + circ2.x)/2 */
       ((), "|-", "circ2"),                 /* Move vertically to circ2.y */
       "circ2",                             /* Same as 1. but for circ2 */
      mark: (start: ">", fill: black))
})

With "circ2" at (…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by psads-git
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants