Skip to content

Edge: Relative coordinate shorthands are incorrect when using non-default axes #104

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

Open
deffi opened this issue May 12, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@deffi
Copy link
Contributor

deffi commented May 12, 2025

Describe the bug

With axes: (rtl, ttb) (instead of the default (ltr, ttb)), relative coordinate shorthand "r" moves left instead of right.

Similarly, with axes: (ltr, btt), relative coordinate shorthand "u" moves down instead of up.

One use case for axes: (ltr, btt) is to align the axes with those of CetZ (i.e., positive y pointing up), so we can switch between elastic coordinates (e.g., (2, 1)) and absolute coordinates (e.g., (2cm, 1cm)) without flipping the sign. But now, we have to flip the relative coordinate shorthands instead.

To Reproduce

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

#diagram(
  debug: 3,
  edge-stroke: 1pt,
  node-stroke: 1pt,
  axes: (ltr, btt),

  node((0,0), [1]),
  edge("r,d", ["r,d"])  // Goes right, up (expected: right, down)
)

#diagram(
  debug: 3,
  edge-stroke: 1pt,
  node-stroke: 1pt,
  axes: (rtl, ttb),

  node((0,0), [2]),
  edge("r,d", ["r,d"])  // Goes left, down (expected: right, down)
)

#diagram(
  debug: 3,
  edge-stroke: 1pt,
  node-stroke: 1pt,
  axes: (ttb, ltr),

  node((0,0), [3]),
  edge("r,d", ["r,d"])  // Goes down, right (expected: right, down)
)

Image

Expected behavior

"r"/"l"/"u"/"d" should go right/left/up/down, respectively, regardless of axes orientation. See the code above for specific examples.

Version information

typst 0.13.1 (8ace67d9)

@deffi deffi added the bug Something isn't working label May 12, 2025
@Jollywatt
Copy link
Owner

The reason I didn't do this from the start was because it is nice to be able to change a diagram's axes after the fact, to try new layouts, but if r/l/u/d/etc were invariant then some diagrams would break. However, I agree that the current behaviour also seems silly, so that it's probably better to fix this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants