Safe Haskell | None |
---|
Contains all data structures for describing transitions, composing and animating them.
- type Transition a = StateT a (Writer [(a, Time)])
- data TransitionStatus
- class Interpolate a where
- interpolate :: Double -> a -> a -> a
- waypoint :: Interpolate a => a -> Time -> Transition a a
- startWith :: Interpolate a => a -> Transition a b -> InternalTransition a
- fromList :: Interpolate a => [(a, Time)] -> InternalTransition a
- transition :: Interpolate a => SignalGen (Signal Time) -> SignalGen (Signal TransitionStatus) -> InternalTransition a -> SignalGen (Signal a)
- length :: InternalTransition a -> Double
Types
type Transition a = StateT a (Writer [(a, Time)])Source
A type describing a combosable transition. The writer keeps record of all the frames in the transition. The state holds the current value of the transition. This allows you to easily compose transitions using do notation.
data TransitionStatus Source
A variety of statuses that can be used to control a transition.
class Interpolate a whereSource
Defines a value that can be interpolated. An example instance of this class follows:
data YourDataType = YourDataConstructor SomeInterpolableType SomeOtherInterpolableType deriving Generic instance Interpolate YourDataType interpolate 0.5 (YourDataConstructor 3 5) (YourDataConstructor 5 7) == YourDataConstructor 4 6
interpolate :: Double -> a -> a -> aSource
Interpolate Bool | |
Interpolate Char | |
Interpolate Double | |
Interpolate Float | |
Interpolate Int | |
Interpolate Int8 | |
Interpolate Int16 | |
Interpolate Int32 | |
Interpolate Int64 | |
Interpolate Integer | |
Interpolate Word | |
Interpolate Word8 | |
Interpolate Word16 | |
Interpolate Word32 | |
Interpolate Word64 | |
Interpolate Color | |
Interpolate (Double, Double) |
Creating
waypoint :: Interpolate a => a -> Time -> Transition a aSource
Adds a value to the transition monad that will be the next point in the transition.
startWith :: Interpolate a => a -> Transition a b -> InternalTransition aSource
Starts a transition with an initial value.
color = transition (constant $ Time.fps 60) (constant Cycle) $ startWith white $ do waypoint green (2 * second) waypoint red (5 * second) waypoint black (1 * second) waypoint yellow (2 * second)
fromList :: Interpolate a => [(a, Time)] -> InternalTransition aSource
Converts a list of tuples describing a waypoint value and time into a transition. The first element in the list is the starting value and time of the transition.
color = transition (constant $ Time.fps 60) (constant Cycle) $ fromList [(white, 0), (green, 2 * second), (red, 5 * second), (black, 1 * second), (yellow, 2 * second)]
Transitions
transition :: Interpolate a => SignalGen (Signal Time) -> SignalGen (Signal TransitionStatus) -> InternalTransition a -> SignalGen (Signal a)Source
Turns the internal representation of a transition into a signal. The provided time signal acts as the inner clock of the transition. The status signal can be used to control the transition, deciding whether the transition should cycle, go to a specific time, pause, stop or run once.