benimator icon indicating copy to clipboard operation
benimator copied to clipboard

feat: Compile-time "Animation" creation

Open sofianedjerbi opened this issue 1 year ago • 2 comments

Current Behavior

Currently, the Animation structures are constructed at runtime, which works well for dynamic and interactive applications.

Desired Feature

I propose adding the capability to build Animation structures at compile time. This feature would allow developers to define animations that are static and unchanging throughout the application's life, ensuring these animations are constructed and optimized during compilation, reducing runtime overhead and potentially improving the application's overall performance. (The main reason is for design purposes)

Possible Implementation

I believe this feature could be implemented by providing a macro or a set of const functions that allow for the construction of Animation structures with fixed parameters. This way, developers can opt-in to compile time construction where it makes sense for their application.

sofianedjerbi avatar Dec 29 '23 00:12 sofianedjerbi

Thanks for the suggestion, and sorry for the delayed response.

It's an interesting Idea. However, it is unclear to me if the value would be worth the added complexity. Even animations that never need to change can be created at startup without noticeable performance cost.

If someone proposes a concrete implementation (via a pull request), I may consider merging it. But even in that case, I may reject the PR if I feel it's adding too much complexity.

If you would like to try creating a PR, make sure to:

  • gate that functionality behind a new feature flag named unstable-comptime
  • write automated tests

jcornaz avatar Feb 20 '24 09:02 jcornaz

That being said, if it can be done without much more complexity than a handful of simple const functions, then I am up for it :smiley:

jcornaz avatar Feb 20 '24 15:02 jcornaz