Skip to content

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

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.

@johannes-wolf
Copy link
Member Author

Rebased on master.

@jamesrswift
Copy link
Contributor

Is there any additional work needing doing on this?

@johannes-wolf
Copy link
Member Author

Is there any additional work needing doing on this?

No, but we lose stack traces for bad coordinates.

The problem with stack traces is, that the Typst Web-App does not show them anyway. So
I guess panic is enough to hint the user. If Typst gave the option to get some kind of “stack trace handle” that you can use with panic, that would be great.

@johannes-wolf johannes-wolf modified the milestones: 0.3.2, 0.4.0 Jan 23, 2025
@johannes-wolf
Copy link
Member Author

johannes-wolf commented Jun 6, 2025

I want to get this into 0.4.0 and I am willing to sacrifice the stack traces for having this feature. I guess we can add better stack-traces/errors with a later PR or release.

The current coordinate validation isn't that helpful anyway, as wrong element names etc. are missing the correct code location.

@johannes-wolf johannes-wolf force-pushed the ctx-coordinate-resolve branch from 645b111 to 12805a7 Compare June 6, 2025 20:43
@johannes-wolf johannes-wolf merged commit 6528b53 into master Jun 6, 2025
1 check passed
@johannes-wolf johannes-wolf deleted the ctx-coordinate-resolve branch September 27, 2025 14:07
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.

4 participants