-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Animation for sprites
--
-- Prototypical sprite animation with type-safety.
@package animate
@version 0.2.0
module Data.Animate
-- | Avoided newtype wrapper for convenience
type Seconds = Float
-- | Type aliased seconds
type DeltaSeconds = Seconds
-- | Alias for RGB (8bit, 8bit, 8bit)
type Color = (Word8, Word8, Word8)
type FrameIndex = Int
data Frame loc
Frame :: loc -> Seconds -> Frame loc
-- | Type safe animation set. Use an sum type with an Enum and
-- Bounded instance for the animation, a.
data Animations key loc
data Loop
-- | Never stop looping. Animation can never be completed.
Loop'Always :: Loop
-- | Count down loops to below zero. 0 = no loop. 1 = one loop. 2 = two
-- loops. etc.
Loop'Count :: Int -> Loop
-- | State for progression through an animation | `example = Position
-- minBound 0 0 LoopAlways
data Position key
Position :: key -> FrameIndex -> Seconds -> Loop -> Position key
-- | You can ignore. An intermediate type for stepPosition to judge
-- how to increment the current frame.
data FrameStep
-- | New counter to compare against the frame's delay.
FrameStep'Counter :: Seconds -> FrameStep
-- | How much delta to carry over into the next frame.
FrameStep'Delta :: DeltaSeconds -> FrameStep
-- | Sematically for an animation key constraint
class (Ord key, Bounded key, Enum key) => Key key
-- | Animation Keyframe. keyName is used for JSON parsing.
class Key key => KeyName key
keyName :: KeyName key => key -> Text
-- | Describe the boxed area of the 2d sprite inside a sprite sheet
data SpriteClip
SpriteClip :: Int -> Int -> Int -> Int -> Maybe (Int, Int) -> SpriteClip
-- | Generalized sprite sheet data structure
data SpriteSheet key img
SpriteSheet :: Animations key SpriteClip -> img -> SpriteSheet key img
-- | One way to represent sprite sheet information. | JSON loading is
-- included.
data SpriteSheetInfo
SpriteSheetInfo :: FilePath -> Maybe Color -> [SpriteClip] -> Map Text [(FrameIndex, Seconds)] -> SpriteSheetInfo
-- | Generate animations given each constructor
animations :: Key key => (key -> [Frame loc]) -> Animations key loc
-- | Lookup the frames of an animation
framesByAnimation :: Key key => Animations key loc -> key -> Vector (Frame loc)
-- | New Position with its animation key to loop forever
initPosition :: Key key => key -> Position key
-- | New Position with its animation key with a limited loop
initPositionLoops :: Key key => key -> Int -> Position key
-- | New Position
initPositionWithLoop :: Key key => key -> Loop -> Position key
-- | Intermediate function for how a frame should be step through.
stepFrame :: Frame loc -> Position key -> DeltaSeconds -> FrameStep
-- | Step through the animation resulting a new position.
stepPosition :: Key key => Animations key loc -> Position key -> DeltaSeconds -> Position key
-- | The animation has finished all its frames. Useful for signalling into
-- switching to another animation. With a Loop'Always, the animation will
-- never be completed.
isAnimationComplete :: Key key => Animations key loc -> Position key -> Bool
-- | Simple function diff'ing the position for loop change
positionHasLooped :: Position key -> Position a -> Bool
-- | Use the position to find the current frame of the animation.
currentFrame :: Key key => Animations key loc -> Position key -> Frame loc
-- | Use the position to find the current location, lik a sprite sheet
-- clip, of the animation.
currentLocation :: Key key => Animations key loc -> Position key -> loc
-- | Cycle through the next animation key
nextKey :: Key key => key -> key
-- | Cycle through the previous animation key
prevKey :: Key key => key -> key
-- | Quick function for loading SpriteSheetInfo. | Check the
-- example.
readSpriteSheetInfoJSON :: FilePath -> IO SpriteSheetInfo
-- | Quick function for loading SpriteSheetInfo, then using it to
-- load its image for a SpriteSheet | Check the example.
readSpriteSheetJSON :: KeyName key => (FilePath -> Maybe Color -> IO img) -> FilePath -> IO (SpriteSheet key img)
instance GHC.Classes.Eq Data.Animate.FrameStep
instance GHC.Show.Show Data.Animate.FrameStep
instance GHC.Classes.Eq key => GHC.Classes.Eq (Data.Animate.Position key)
instance GHC.Show.Show key => GHC.Show.Show (Data.Animate.Position key)
instance GHC.Classes.Eq Data.Animate.Loop
instance GHC.Show.Show Data.Animate.Loop
instance GHC.Classes.Eq Data.Animate.SpriteSheetInfo
instance GHC.Show.Show Data.Animate.SpriteSheetInfo
instance GHC.Classes.Eq Data.Animate.SpriteClip
instance GHC.Show.Show Data.Animate.SpriteClip
instance GHC.Classes.Eq loc => GHC.Classes.Eq (Data.Animate.Animations key loc)
instance GHC.Show.Show loc => GHC.Show.Show (Data.Animate.Animations key loc)
instance GHC.Classes.Eq loc => GHC.Classes.Eq (Data.Animate.Frame loc)
instance GHC.Show.Show loc => GHC.Show.Show (Data.Animate.Frame loc)
instance Data.Aeson.Types.ToJSON.ToJSON Data.Animate.SpriteClip
instance Data.Aeson.Types.FromJSON.FromJSON Data.Animate.SpriteClip
instance Data.Aeson.Types.ToJSON.ToJSON Data.Animate.SpriteSheetInfo
instance Data.Aeson.Types.FromJSON.FromJSON Data.Animate.SpriteSheetInfo