HACKER Q&A
📣 elviejo

Is there a declarative animation language?


I'm looking for a programming language for graphics. Something like processing.org but more declarative.

for example if I had a circle with center in 0,0 and then I exited to have center in 100,100 then the animation to transform from one to the other should happen automatically.

something that looks like:

(circle 0,0) `animate` (circle 100,100).

or even better animate automatically between scenes, where a scene is a set of other drawings. so animate from scene to the next would be like:

scene1 `animate` scene2

does something like that exist?


  👤 brudgers Accepted Answer ✓

👤 bartvk
SwiftUI has features like that

    struct AnimatedCircle: View {
        @State private var radius: CGFloat = 0
        var body: some View {
            Circle()
                .frame(width: radius, height: radius)
                .onAppear {
                    withAnimation {
                        self.radius = 100
                    }
                }
        }
    }

👤 Someone
XML-based, so a bit wordy, but css animations are declarative and can be combined with svg. See for example https://css-tricks.com/guide-svg-animations-smil.

https://en.wikipedia.org/wiki/Synchronized_Multimedia_Integr... takes that a bit further by allowing animation of other things than attributes.



👤 shirogane86x
Haskell has reanimate (https://reanimate.github.io/), although I don't personally have much experience with it. But it does have an online playground to try out stuff in the browser

👤 byoung2
http://paperjs.org/about/ might be a good starting point