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

[feature request] anchors for line's coordinates #640

Open
tapyu opened this issue Jul 3, 2024 · 6 comments
Open

[feature request] anchors for line's coordinates #640

tapyu opened this issue Jul 3, 2024 · 6 comments
Labels
feature 🎁 Feature Request

Comments

@tapyu
Copy link
Contributor

tapyu commented Jul 3, 2024

In

line(
    (0,1),
    (0,2),
    (0,3),
    mark: (end: ">"),
    name: "line"
  )

it would be interesting to have anchors to the coordinates that makes the line up. AFAIK CeTZ doesn't provide such anchor.

I propose the syntax "line.i" to access the ith coordinate. For instance, in "line", "line.1" would access (0,1), "line.2" would access (0,2), and so on.

PS: Path anchor (e.g., "line.30%") is not convenient when the line is very complex, so it is not a reasonable alternative.

@johannes-wolf
Copy link
Member

Since <element>.<int> is already used for absolute length along a path, we could add anchors with a prefix like pt-: line.pt-1. What do you think?

@johannes-wolf johannes-wolf added the feature 🎁 Feature Request label Jul 3, 2024
@tapyu
Copy link
Contributor Author

tapyu commented Jul 4, 2024

I see...

we could add anchors with a prefix like pt-: line.pt-1.

Are you proposing to add such prefix for absolute length anchors and leave the syntax "line.i" for my proposed anchor, right? If so, I think it is a good idea. However, I would suggest a small change: instead of "line.pt-1", I would adopt "line.1pt" for two reasons:

  1. 1pt matches with the syntax used for length types variables.
  2. No extra fancy - character is required.

Moreover, I think this "new" (AFAIU) anchor type deserves a subsection in sec 2.2 of CeTZ. It is distinct enough from named, border, and path anchor type. What do you think? I think so because the way we access it not based on a path, compass or angle, or a mere name. Rather, it is the ith coordinate used to construct the object (in this case, a line). I think the terms "coordinate anchor" or "order anchor" are good candidates to refer to it.

@fenjalien
Copy link
Member

Are you proposing to add such prefix for absolute length anchors and leave the syntax "line.i" for my proposed anchor, right?

No, when using shorthand anchors, anchors that start with a digit are reserved for path anchors if the element supports them. What @johannes-wolf has proposed is that for each coordinate given to the line function a pt-i named anchor will be created, where i is the index of the coordinate. This is similar to how a bezier's control points are given anchors.

@tapyu
Copy link
Contributor Author

tapyu commented Jul 4, 2024

Ah :( Well, it is up to you. I think pt-i too wordy, to be honest, but okay.

@johannes-wolf
Copy link
Member

Something like pt-0, pt-1 is too wordy?

@tapyu
Copy link
Contributor Author

tapyu commented Jul 6, 2024

Yes. Four characters when only one is actually useful.

This is obviously a matter of opinion, though. Fell free to disregard my point of view. Although it is verbose, pt-i is good, don't get me wrong. More importantly, this is the syntax used in CeTZ, like catmull, so I think it is the way-to-go for the sake of consistency.

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