-- | Display mode is for drawing a static picture.
module Brillo.Interface.Pure.Animate (
  module Brillo.Data.Display,
  module Brillo.Data.Picture,
  module Brillo.Data.Color,
  animate,
)
where

import Brillo.Data.Color
import Brillo.Data.Display
import Brillo.Data.Picture
import Brillo.Internals.Interface.Animate
import Brillo.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 =
  GLFWState
-> Bool
-> Display
-> Color
-> (Float -> IO Picture)
-> (Controller -> IO ())
-> IO ()
forall a.
Backend a =>
a
-> Bool
-> Display
-> Color
-> (Float -> IO Picture)
-> (Controller -> IO ())
-> IO ()
animateWithBackendIO
    GLFWState
defaultBackendState
    Bool
True -- pannable
    Display
display
    Color
backColor
    (Picture -> IO Picture
forall a. a -> IO a
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 a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()))