reflex-animation 0.1.4 → 0.1.5
raw patch · 3 files changed
+6/−19 lines, 3 files
Files
- reflex-animation.cabal +1/−1
- src/Reflex/Animation.hs +3/−2
- src/Reflex/Monad/Time.hs +2/−16
reflex-animation.cabal view
@@ -1,5 +1,5 @@ name: reflex-animation-version: 0.1.4+version: 0.1.5 synopsis: Continuous animations support for reflex description: This package provides a set of functions for creating and playing continuous animations of the form Time -> a. Finite animations (with a length) and infinite animations complement one another, we chose a representation of
src/Reflex/Animation.hs view
@@ -34,6 +34,9 @@ , sine , cosine + , clamp+ , fmod+ ) where@@ -221,8 +224,6 @@ | otherwise = (frac + 1) * d where (_::Int, frac) = properFraction (x / d) - - clamp :: Ord a => (a, a) -> a -> a clamp (lower, upper) a = max lower (min upper a)
src/Reflex/Monad/Time.hs view
@@ -1,14 +1,13 @@ module Reflex.Monad.Time ( MonadTime (..) - , observeChanges , delay_ , animate , animateClip , animateOn- + , play , playClip , playClamp@@ -40,15 +39,7 @@ class (MonadReflex t m, RealFrac time) => MonadTime t time m | m -> t time where-- -- | Integrate a behavior with respect to time, at a sampling rate determined by the implementor- -- uses VectorSpace to allow for monomorphic vectors, e.g. gloss- integrate :: (VectorSpace v, Scalar v ~ time) => v -> Behavior t v -> m (Behavior t v) - -- | Observe an event by sampling it at a rate determined by the implementing framework- -- e.g. reflex-gloss-scene uses a fixed sampling rate.- observe :: Behavior t a -> m (Event t a)- -- | A behavior for time, must be up to date -- (i.e. represents current time not previous time) getTime :: m (Behavior t time)@@ -84,6 +75,7 @@ + -- | Create a Behavior from an infinite animation on the occurance of the event animateOn :: (Reflex t, RealFrac time) => Event t (Animation time a) -> Behavior t time -> Event t (Behavior t a) animateOn e = sampleOn (sampleAt <$> e)@@ -133,12 +125,6 @@ return (join b, done) --- | Observe changes in a 'Behavior a' it's Eq a instance-observeChanges :: (Eq a, MonadTime t time m) => Behavior t a -> m (Event t a)-observeChanges b = do- initial <- sample b- d <- holdDyn initial =<< observe b- return (updated $ nubDyn d) -- | Helper functions using filter with Eq