-- | Animate a picture in a window.
module Brillo.Interface.IO.Animate (
  module Brillo.Data.Display,
  module Brillo.Data.Picture,
  module Brillo.Data.Color,
  animateIO,
  animateFixedIO,
  Controller (..),
)
where

import Brillo.Data.Color
import Brillo.Data.Controller
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@.
-}
animateIO ::
  -- | Display mode.
  Display ->
  -- | Background color.
  Color ->
  {-| Function to produce the next frame of animation.
     It is passed the time in seconds since the program started.
  -}
  (Float -> IO Picture) ->
  -- | Callback to take the display controller.
  (Controller -> IO ()) ->
  IO ()
animateIO :: Display
-> Color -> (Float -> IO Picture) -> (Controller -> IO ()) -> IO ()
animateIO
  Display
display
  Color
backColor
  Float -> IO Picture
frameFunIO
  Controller -> IO ()
eatControllerIO =
    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
      Float -> IO Picture
frameFunIO
      Controller -> IO ()
eatControllerIO


-- | Like `animateIO` but don't allow the display to be panned around.
animateFixedIO ::
  -- | Display mode.
  Display ->
  -- | Background color.
  Color ->
  {-| Function to produce the next frame of animation.
     It is passed the time in seconds since the program started.
  -}
  (Float -> IO Picture) ->
  -- | Callback to take the display controller.
  (Controller -> IO ()) ->
  IO ()
animateFixedIO :: Display
-> Color -> (Float -> IO Picture) -> (Controller -> IO ()) -> IO ()
animateFixedIO
  Display
display
  Color
backColor
  Float -> IO Picture
frameFunIO
  Controller -> IO ()
eatControllerIO =
    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
False
      Display
display
      Color
backColor
      Float -> IO Picture
frameFunIO
      Controller -> IO ()
eatControllerIO