moduleGraphics.Gloss.Internals.Interface.Animate(animate,animateWithBackend)whereimportGraphics.Gloss.Data.ColorimportGraphics.Gloss.Data.PictureimportGraphics.Gloss.Internals.Render.PictureimportGraphics.Gloss.Internals.Render.ViewPortimportGraphics.Gloss.Internals.Interface.BackendimportGraphics.Gloss.Internals.Interface.WindowimportGraphics.Gloss.Internals.Interface.Common.ExitimportGraphics.Gloss.Internals.Interface.ViewPortimportGraphics.Gloss.Internals.Interface.ViewPort.KeyMouseimportGraphics.Gloss.Internals.Interface.ViewPort.MotionimportGraphics.Gloss.Internals.Interface.ViewPort.ReshapeimportGraphics.Gloss.Internals.Interface.Animate.TimingimportqualifiedGraphics.Gloss.Internals.Render.StateasRSimportqualifiedGraphics.Gloss.Internals.Interface.ViewPort.ControlStateasVPCimportqualifiedGraphics.Gloss.Internals.Interface.Animate.StateasANimportqualifiedGraphics.Gloss.Internals.Interface.CallbackasCallbackimportData.IORefimportControl.MonadimportSystem.MemimportGHC.Float(double2Float)-- | 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=animateWithBackenddefaultBackendStateanimateWithBackend::Backenda=>a-- ^ Initial State of the backend->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()animateWithBackendbackenddisplaybackColorframeFun=doviewSR<-newIORefviewPortInitviewControlSR<-newIORefVPC.stateInitanimateSR<-newIORefAN.stateInitrenderS_<-RS.stateInitrenderSR<-newIORefrenderS_letdisplayFunbackendRef=do-- extract the current time from the statetimeS<-animateSR`getsIORef`AN.stateAnimateTime-- call the user function to get the animation frameletpicture=frameFun(double2FloattimeS)renderS<-readIORefrenderSRviewS<-readIORefviewSR-- render the framewithViewPortbackendRefviewS(renderPicturebackendRefrenderSviewSpicture)-- perform GC every frame to try and avoid long pausesperformGCletcallbacks=[Callback.Display(animateBeginanimateSR),Callback.DisplaydisplayFun,Callback.Display(animateEndanimateSR),Callback.Idle(\s->postRedisplays),callback_exit(),callback_viewPort_keyMouseviewSRviewControlSR,callback_viewPort_motionviewSRviewControlSR,callback_viewPort_reshape]createWindowbackenddisplaybackColorcallbacksgetsIORef::IORefa->(a->r)->IOrgetsIORefreffun=liftMfun$readIORefref