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

canvas: Support custom coordinate systems #719

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

johannes-wolf
Copy link
Member

@johannes-wolf johannes-wolf commented Oct 12, 2024

Proposal: Add the option to use custom coordinates by providing an option to register a callback for "pre-resolving" coordinates.

Motivation: Being able to handle plot/axis coordinates differently than "normal" coordinates in cetz-plot. But this feature could also be used to implement a tangent system on paths etc. I have not looked at the sources of fletcher, but it may be interesting to them, too.

Copy link
Member

@fenjalien fenjalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a cool idea, feels similar to the modifier plans but I don't think theres a way we can connect them somehow.
shame about how it effects the error warnings for the user

@@ -116,8 +116,6 @@
assert.eq(style.pos(), (), message: "Unexpected positional arguments: " + repr(style.pos()))
style = style.named()

(a, b, c).map(coordinate.resolve-system)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these should be removed, they help tell the user where they've entered an invalid coordinate

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I see why they've been removed, thats a really difficult trade off.
Is there a way we could keep track of how many or which draw functions have been created and let the user know about it? Essentially create our own stack trace. It probably shouldn't go in this pr but I would like to at least explore it before this pr gets approved.

Copy link
Member Author

@johannes-wolf johannes-wolf Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add some trace list to the context, that gets shown with any panic/assert we do. Something like element information (function name + element name, if given). This might be slow though, as we have to append and merge that list for every element.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created a PR for a possible implementation of such functionality here: #726.

src/coordinate.typ Outdated Show resolved Hide resolved
src/coordinate.typ Outdated Show resolved Hide resolved
@johannes-wolf
Copy link
Member Author

Rebased on master.

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

Successfully merging this pull request may close these issues.

2 participants