diff --git a/examples/example02.hs b/examples/example02.hs index 8d29e3f..ffa6bde 100644 --- a/examples/example02.hs +++ b/examples/example02.hs @@ -86,11 +86,8 @@ load _ = do draw :: Affection UserData () draw = do traceM "drawing" - ad <- get UserData{..} <- getAffection - SDL.V2 (CInt rw) (CInt rh) <- SDL.surfaceDimensions $ drawSurface ad - let (w, h) = (fromIntegral rw, fromIntegral rh) - liftIO $ clearArea foreground (GeglRectangle 0 0 w h) + clear foreground maybe (return ()) (\(x, y) -> drawRect (nodeGraph M.! "nop") diff --git a/src/Affection/Draw.hs b/src/Affection/Draw.hs index 7b50933..6c6ffea 100644 --- a/src/Affection/Draw.hs +++ b/src/Affection/Draw.hs @@ -3,7 +3,7 @@ -- | Module for drawing primitives module Affection.Draw ( drawRect - -- , clear + , clear , handleDrawRequest , invalidateDrawRequest , present @@ -186,3 +186,11 @@ clearArea -> G.GeglRectangle -- ^ Area to clear -> IO () clearArea = G.gegl_buffer_clear + +-- | Clear the whole drawing area +clear :: G.GeglBuffer -> Affection us () +clear buffer = do + ad <- get + SDL.V2 (CInt rw) (CInt rh) <- SDL.surfaceDimensions $ drawSurface ad + let (w, h) = (fromIntegral rw, fromIntegral rh) + liftIO $ clearArea buffer (GeglRectangle 0 0 w h)