Scoped `state()`?

This sounds like you’re looking for custom types—here’s one relevant thread from the forum: (How) can I define a new type in the Typst scripting language? (I also recommend the linked blog post; so yes, it’s on the roadmap).

For now, there is the Elembic package which does something (probably) similar to your ellipse hack, but may be better tested and more featureful, meaning you may be able to fix your issues using it. You should note though that fundamentally, Elembic is meant to be superseded by a built-in Typst feature, so using it is somewhat experimental. That said, lilaq, a pretty big graphics package, uses it too, so using elembic in a production-grade package is also not unheard of.

2 Likes