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

Generic line shortening #790

Open
janosh opened this issue Jan 8, 2025 · 1 comment
Open

Generic line shortening #790

janosh opened this issue Jan 8, 2025 · 1 comment
Assignees
Labels
feature 🎁 Feature Request
Milestone

Comments

@janosh
Copy link
Contributor

janosh commented Jan 8, 2025

it's already possible to use mark: (offset: <offset>) to shorten lines with marks.
but you can't shorten arbitrary unmarked lines. would be nice to have a generic shorten option on line

Originally posted by @johannes-wolf in #788 (comment)

@johannes-wolf johannes-wolf added the feature 🎁 Feature Request label Jan 9, 2025
@johannes-wolf johannes-wolf self-assigned this Jan 23, 2025
@johannes-wolf johannes-wolf added this to the 0.4.0 milestone Jan 23, 2025
@knuesel
Copy link

knuesel commented Feb 24, 2025

Another possibility would be to honor the offset even when the symbol is none:

#import "@preview/cetz:0.3.2"

#cetz.canvas({
  import cetz.draw: *
  line((0, 0), (4, 0))
  // Doesn't work, but this could be fixed?
  line((0, -1), (4, -1), mark: (end: none, offset: 1cm))
  // Works but ugly:
  line((0, -2), (4, -2), mark: (end: ">", offset: 1cm, scale: 0))
})

Image

But I guess having a shorten option on paths would be cleaner. It could take a value (number or ratio) or a dict (start: ..., end: ...).

Edit: I'm not sure honoring the offset when the symbol is none would be a good idea: if the user does line((0, 0), (4, 0), mark: (end: ">", offset: 1cm)), the start mark is none, and it probably should not be shortened. So a shorten option seems like a better solution to me.

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

No branches or pull requests

3 participants