rename drawRect' to drawRect and clean Affection.Draw

This commit is contained in:
nek0 2016-12-26 14:14:54 +01:00
parent 7837a14456
commit 10c889af56
3 changed files with 5 additions and 76 deletions

View file

@ -86,7 +86,7 @@ draw :: Affection UserData ()
draw = do
traceM "drawing"
UserData{..} <- getAffection
drawRect' (nodeGraph M.! "nop") (G.RGB 1 0 0) Fill (G.GeglRectangle 10 10 500 500) foreground
drawRect (nodeGraph M.! "nop") (G.RGB 1 0 0) Fill (G.GeglRectangle 10 10 500 500) foreground
liftIO $ G.gegl_node_process $ nodeGraph M.! "sink"
update :: Double -> AffectionState (AffectionData UserData) IO ()

View file

@ -90,7 +90,7 @@ draw = do
let (w, h) = (fromIntegral rw, fromIntegral rh)
liftIO $ clearArea foreground (GeglRectangle 0 0 w h)
maybe (return ()) (\(x, y) ->
drawRect'
drawRect
(nodeGraph M.! "nop")
(G.RGBA 1 0 0 0.5)
(Fill)

View file

@ -2,9 +2,7 @@
-- | Module for drawing primitives
module Affection.Draw
(
-- drawRect
drawRect'
( drawRect
-- , clear
, handleDrawRequest
, invalidateDrawRequest
@ -30,53 +28,14 @@ import qualified GEGL as G
import Debug.Trace
-- | Draw a rectangle on target buffer
-- drawRect
-- :: G.GeglBuffer -- ^ Target buffer
-- -> G.GeglNode -- ^ Target node
-- -> G.Color -- ^ Color to draw in
-- -> DrawType -- ^ Draw type
-- -> GeglRectangle -- ^ Dimensions of Rectangle
-- -> Affection us ()
-- drawRect buf node color (Fill) rect@G.GeglRectangle{..} = do
-- liftIO $ G.pixelPoke buf rect (B.PixelFormat B.RGBA B.CFdouble) G.GeglAccessReadWrite G.GeglAbyssNone $
-- (\(x, y) ->
-- let col = unsafeColorize color
-- in
-- G.Pixel x y col
-- )
-- ad@AffectionData{..} <- get
-- put $ ad
-- { drawStack = (DrawRequest rect buf False) : drawStack
-- }
-- drawRect buf node color (Line size) rect@G.GeglRectangle{..} = do
-- liftIO $ G.pixelPoke buf rect (B.PixelFormat B.RGBA B.CFdouble) G.GeglAccessReadWrite G.GeglAbyssNone $
-- (\(x, y) ->
-- let col = unsafeColorize color
-- in if not ((x >= rectangleX + size && x < rectangleX + rectangleWidth - size) &&
-- (y >= rectangleY + size && y < rectangleY + rectangleHeight - size))
-- then
-- G.Pixel x y col
-- else
-- G.Pixel x y $ unsafeColorize $ G.RGBA 0 0 0 0
-- )
-- ad@AffectionData{..} <- get
-- put $ ad
-- { drawStack = (DrawRequest rect buf False) : drawStack
-- }
-- -- drawRect buf node color Fill (G.GeglRectangle rectangleX rectangleY rectangleWidth size)
-- -- drawRect buf node color Fill (G.GeglRectangle rectangleX rectangleY size rectangleHeight)
-- -- drawRect buf node color Fill (G.GeglRectangle (rectangleX + rectangleWidth - size) rectangleY size rectangleHeight)
-- -- drawRect buf node color Fill (G.GeglRectangle rectangleX (rectangleY + rectangleHeight - size) rectangleWidth size)
drawRect'
drawRect
:: G.GeglNode -- ^ Target Node
-> G.Color -- ^ Color to draw in
-> DrawType -- ^ Draw type
-> G.GeglRectangle -- ^ Dimensions of Rectangle
-> G.GeglBuffer -- ^ Final Buffer
-> Affection us ()
drawRect' node color Fill rect@GeglRectangle{..} buf = do
drawRect node color Fill rect@GeglRectangle{..} buf = do
ad <- get
tempRoot <- liftIO $ G.gegl_node_new
opNode <- liftIO $ G.gegl_node_new_child tempRoot $ G.Operation "gegl:rectangle"
@ -105,30 +64,6 @@ present rect buf kill = do
{ drawStack = (DrawRequest rect buf k) : drawStack ad
}
-- -- | force a blit of a specified area. Do not use often as it slows down the program
-- present
-- :: G.GeglNode -- ^ Node to blit
-- -> G.GeglBuffer -- ^ BUffer to draw
-- -> G.GeglRectangle -- ^ Area to blit
-- -> Bool -- ^ Shall the drawing be cleared in the next run?
-- -> Affection us ()
-- present node buf rect pers = do
-- ad <- get
-- put $ ad
-- { drawStack = (DrawRequest rect buf pers) : drawStack ad
-- }
-- ad <- get
-- format <- liftIO $ B.babl_format $ B.PixelFormat B.RGBA B.CFu8
-- liftIO $ SDL.lockSurface $ drawSurface ad
-- liftIO $ G.gegl_node_blit
-- rect
-- format
-- nullPtr
-- 0
-- [G.GeglBlitDefault]
-- liftIO $ SDL.unlockSurface $ drawSurface ad
-- liftIO $ SDL.updateWindowSurface $ drawWindow ad
-- | function for handling 'DrawRequest's and updating the output
handleDrawRequest
:: Ptr a -- ^ Pixel buffer to blit to
@ -233,12 +168,6 @@ unsafeColorize col =
, G.CVdouble $ CDouble $ a
)
-- -- | Clear all data from a buffer
-- clear
-- :: G.GeglBuffer -- ^ Target buffer
-- -> IO ()
-- clear buf = clearArea buf =<< G.gegl_rectangle_infinite_plane
-- | Clear a specified area of a buffer from all data
clearArea
:: G.GeglBuffer -- ^ Target buffer