-- | Display mode is for drawing a static picture.
module Graphics.Gloss.Interface.Pure.Animate
        ( module Graphics.Gloss.Data.Display
        , module Graphics.Gloss.Data.Picture
        , module Graphics.Gloss.Data.Color
        , animate)
where
import Graphics.Gloss.Data.Display
import Graphics.Gloss.Data.Picture
import Graphics.Gloss.Data.Color
import Graphics.Gloss.Internals.Interface.Animate
import Graphics.Gloss.Internals.Interface.Backend


-- | Open a new window and display the given animation.
--
--   Once the window is open you can use the same commands as with `display`.
--
animate :: Display              -- ^ Display mode.
        -> Color                -- ^ Background color.
        -> (Float -> Picture)   -- ^ Function to produce the next frame of animation.
                                --      It is passed the time in seconds since the program started.
        -> IO ()

animate :: Display -> Color -> (Float -> Picture) -> IO ()
animate Display
display Color
backColor Float -> Picture
frameFun
        = GLUTState
-> Bool
-> Display
-> Color
-> (Float -> IO Picture)
-> (Controller -> IO ())
-> IO ()
forall a.
Backend a =>
a
-> Bool
-> Display
-> Color
-> (Float -> IO Picture)
-> (Controller -> IO ())
-> IO ()
animateWithBackendIO
                GLUTState
defaultBackendState
                Bool
True            -- pannable
                Display
display Color
backColor
                (Picture -> IO Picture
forall (m :: * -> *) a. Monad m => a -> m a
return (Picture -> IO Picture)
-> (Float -> Picture) -> Float -> IO Picture
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Float -> Picture
frameFun)
                (IO () -> Controller -> IO ()
forall a b. a -> b -> a
const (() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()))