3 ms·
pedantic stuff: typo here: seq (f, Maybe df) (g, dg) t s/Maybe/Just/ and `par` should be par :: Anim a -> Anim b -> Anim (a, b) par (f, df) (g, dg) =
by uryga 6y ago
pedantic stuff:
typo here:
seq (f, Maybe df) (g, dg) t
s/Maybe/Just/
and `par` should be
par :: Anim a -> Anim b -> Anim (a, b)
par (f, df) (g, dg) = (\t -> (f t, g t), max <$> df <*> dg)
---
i'm not sure about `par` - if my understanding of Anim is right, it'll take the shorter animation over its specified duration. what if it was something like:
par a@(_, da) b@(_, db) = (ab, max <$> da <*> db)
where ab t = (a `at` t, b `at` t)
at :: Anim a -> Duration -> a
at (f, Nothing) t = f t
-- freeze when t exceeds dur, i.e. the animation is done
at (f, Just dur) t = f (min dur t)
might be less elegant but i'd expect the combinator to respect an animation's duration.
or is that not what the duration represents? i.e. is this correct:
stretch :: Float -> Anim a -> Anim a
stretch factor (f, dur) = (\t -> f (t / factor), (factor *) <$> dur)
- reuben364 6y agoThanks. I should have just clarified that I wanted to communicate the idea. I didn't expect to get it right first try. Maybe I'll try and make a small library of it if there isn't already. I've never posted something on Hackage.
- reuben364 6y agoReplying to your edit: As I was writing it my headspace was that the duration was for seq to know when to switch. I wasn't really thinking about stopping the animation too. (I also notices that my seq is wrong. The subsequent animation should start at the beginning, so it should be `g (t - df)`, not `g t` I believe you are correct. Your implementation is more at the heart of what I wanted to show. . The main point I wanted to get across was the interface itself.
- uryga 6y agoit's a nice idea, i was just in a nitpicky mood :)