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

Self-edges only work on top or bottom #36

Open
DusterTheFirst opened this issue May 29, 2024 · 1 comment
Open

Self-edges only work on top or bottom #36

DusterTheFirst opened this issue May 29, 2024 · 1 comment

Comments

@DusterTheFirst
Copy link

When using an edge to point from a node to itself, with bend: 130deg the bend will come either out of the top of the bottom (depending on if bend is negative) however there does not seem to be a way to make the bend come out of the side, either left or right.

@Jollywatt
Copy link
Owner

There is a hack you can use which is why I've not bothered to add a new controller for this:

#import "@preview/fletcher:0.4.5": diagram, node, edge

#diagram({
  node((0,0), [Hello], stroke: 1pt, shape: circle)

  edge((0,-.1), (0,+.1), "-|>", bend: 120deg)

  let polar(r, theta) = (r*calc.cos(theta), r*calc.sin(theta))
  let theta = 45deg
  edge(polar(0.1, theta), polar(-0.1, theta), "-|>", bend: 130deg)
})
Screenshot 2024-05-29 at 22 23 21

By adjusting the edge‘s vertices by small amounts, you change the angle of the line that connects them; this line is then bent into the final arc that you see.

I haven't thought of a good interface for this. We could add a loop-angle option to edge, but then it wouldn't make sense for non-loop edges, and edge() already has lots of options. I want to keep it simple. (Ideas are welcome!) At the very least, there should be some examples in the manual, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants