-- 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.4.0 module Animate -- | Alias for RGB (8bit, 8bit, 8bit) type Color = (Word8, Word8, Word8) type FrameIndex = Int data Frame loc delay Frame :: loc -> delay -> Frame loc delay -- | User defined reference to the location of a sprite. For example, a -- sprite sheet clip. [$sel:fLocation:Frame] :: Frame loc delay -> loc -- | Minimium amount of units for the frame to last. [$sel:fDelay:Frame] :: Frame loc delay -> delay -- | Type safe animation set. Use a sum type with an Enum and -- Bounded instance for the animation, a. newtype Animations key loc delay Animations :: Vector (Vector (Frame loc delay)) -> Animations key loc delay [$sel:unAnimations:Animations] :: Animations key loc delay -> Vector (Vector (Frame loc delay)) 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 Loop'Always --data Position key delay Position :: key -> FrameIndex -> delay -> Loop -> Position key delay -- | Index for the animation. [$sel:pKey:Position] :: Position key delay -> key -- | Index wihin the animation. WARNING: Modifying to below zero or -- equal-to-or-greater-than-the-frame-count will throw out of bounds -- errors. [$sel:pFrameIndex:Position] :: Position key delay -> FrameIndex -- | Accumulated units to end of the frame. Will continue to compound if -- animation is completed. [$sel:pCounter:Position] :: Position key delay -> delay -- | How to loop through an animation. Loop'Count is a count down. [$sel:pLoop:Position] :: Position key delay -> Loop -- | You can ignore. An intermediate type for stepPosition to judge -- how to increment the current frame. data FrameStep delay -- | New counter to compare against the frame's delay. FrameStep'Counter :: delay -> FrameStep delay -- | How much delta to carry over into the next frame. FrameStep'Delta :: delay -> FrameStep delay -- | Semantically 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 [$sel:scX:SpriteClip] :: SpriteClip -> Int [$sel:scY:SpriteClip] :: SpriteClip -> Int [$sel:scW:SpriteClip] :: SpriteClip -> Int [$sel:scH:SpriteClip] :: SpriteClip -> Int [$sel:scOffset:SpriteClip] :: SpriteClip -> Maybe (Int, Int) -- | Generalized sprite sheet data structure data SpriteSheet key img delay SpriteSheet :: Animations key SpriteClip delay -> img -> SpriteSheet key img delay [$sel:ssAnimations:SpriteSheet] :: SpriteSheet key img delay -> Animations key SpriteClip delay [$sel:ssImage:SpriteSheet] :: SpriteSheet key img delay -> img -- | One way to represent sprite sheet information. JSON loading is -- included. data SpriteSheetInfo delay SpriteSheetInfo :: FilePath -> Maybe Color -> [SpriteClip] -> Map Text [(FrameIndex, delay)] -> SpriteSheetInfo delay [$sel:ssiImage:SpriteSheetInfo] :: SpriteSheetInfo delay -> FilePath [$sel:ssiAlpha:SpriteSheetInfo] :: SpriteSheetInfo delay -> Maybe Color [$sel:ssiClips:SpriteSheetInfo] :: SpriteSheetInfo delay -> [SpriteClip] [$sel:ssiAnimations:SpriteSheetInfo] :: SpriteSheetInfo delay -> Map Text [(FrameIndex, delay)] -- | Generate animations given each constructor animations :: Key key => (key -> [Frame loc delay]) -> Animations key loc delay -- | Lookup the frames of an animation framesByAnimation :: Key key => Animations key loc delay -> key -> Vector (Frame loc delay) -- | New Position with its animation key to loop forever initPosition :: (Num delay, Key key) => key -> Position key delay -- | New Position with its animation key with a limited loop initPositionLoops :: (Num delay, Key key) => key -> Int -> Position key delay -- | New Position initPositionWithLoop :: (Num delay, Key key) => key -> Loop -> Position key delay -- | Intermediate function for how a frame should be step through. stepFrame :: (Num delay, Ord delay) => Frame loc delay -> Position key delay -> delay -> FrameStep delay -- | Step through the animation resulting a new position. stepPosition :: (Num delay, Ord delay, Key key) => Animations key loc delay -> Position key delay -> delay -> Position key delay -- | 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, Num delay, Ord delay) => Animations key loc delay -> Position key delay -> Bool -- | Simple function diff'ing the position for loop change. positionHasLooped :: Position key delay -> Position key delay -> Bool -- | Use the position to find the current frame of the animation. currentFrame :: (Num delay, Key key) => Animations key loc delay -> Position key delay -> Frame loc delay -- | Use the position to find the current location, lik a sprite sheet -- clip, of the animation. currentLocation :: (Num delay, Key key) => Animations key loc delay -> Position key delay -> 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 :: FromJSON delay => FilePath -> IO (SpriteSheetInfo delay) -- | Quick function for loading SpriteSheetInfo, then using it to -- load its image for a SpriteSheet. Check the example. readSpriteSheetJSON :: (KeyName key, FromJSON delay) => (FilePath -> Maybe Color -> IO img) -> FilePath -> IO (SpriteSheet key img delay) instance GHC.Generics.Generic (Animate.FrameStep delay) instance GHC.Classes.Eq delay => GHC.Classes.Eq (Animate.FrameStep delay) instance GHC.Show.Show delay => GHC.Show.Show (Animate.FrameStep delay) instance GHC.Generics.Generic (Animate.Position key delay) instance (GHC.Classes.Eq delay, GHC.Classes.Eq key) => GHC.Classes.Eq (Animate.Position key delay) instance (GHC.Show.Show delay, GHC.Show.Show key) => GHC.Show.Show (Animate.Position key delay) instance GHC.Generics.Generic Animate.Loop instance GHC.Classes.Eq Animate.Loop instance GHC.Show.Show Animate.Loop instance GHC.Generics.Generic (Animate.SpriteSheetInfo delay) instance GHC.Classes.Eq delay => GHC.Classes.Eq (Animate.SpriteSheetInfo delay) instance GHC.Show.Show delay => GHC.Show.Show (Animate.SpriteSheetInfo delay) instance GHC.Generics.Generic (Animate.SpriteSheet key img delay) instance GHC.Generics.Generic Animate.SpriteClip instance GHC.Classes.Eq Animate.SpriteClip instance GHC.Show.Show Animate.SpriteClip instance (GHC.Classes.Eq loc, GHC.Classes.Eq delay) => GHC.Classes.Eq (Animate.Animations key loc delay) instance (GHC.Show.Show loc, GHC.Show.Show delay) => GHC.Show.Show (Animate.Animations key loc delay) instance GHC.Generics.Generic (Animate.Frame loc delay) instance (GHC.Classes.Eq delay, GHC.Classes.Eq loc) => GHC.Classes.Eq (Animate.Frame loc delay) instance (GHC.Show.Show delay, GHC.Show.Show loc) => GHC.Show.Show (Animate.Frame loc delay) instance Data.Aeson.Types.ToJSON.ToJSON delay => Data.Aeson.Types.ToJSON.ToJSON (Animate.SpriteSheetInfo delay) instance Data.Aeson.Types.FromJSON.FromJSON delay => Data.Aeson.Types.FromJSON.FromJSON (Animate.SpriteSheetInfo delay) instance Data.Aeson.Types.ToJSON.ToJSON Animate.SpriteClip instance Data.Aeson.Types.FromJSON.FromJSON Animate.SpriteClip