rename drawRect' to drawRect and clean Affection.Draw
This commit is contained in:
parent
7837a14456
commit
10c889af56
3 changed files with 5 additions and 76 deletions
|
@ -86,7 +86,7 @@ draw :: Affection UserData ()
|
||||||
draw = do
|
draw = do
|
||||||
traceM "drawing"
|
traceM "drawing"
|
||||||
UserData{..} <- getAffection
|
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"
|
liftIO $ G.gegl_node_process $ nodeGraph M.! "sink"
|
||||||
|
|
||||||
update :: Double -> AffectionState (AffectionData UserData) IO ()
|
update :: Double -> AffectionState (AffectionData UserData) IO ()
|
||||||
|
|
|
@ -90,7 +90,7 @@ draw = do
|
||||||
let (w, h) = (fromIntegral rw, fromIntegral rh)
|
let (w, h) = (fromIntegral rw, fromIntegral rh)
|
||||||
liftIO $ clearArea foreground (GeglRectangle 0 0 w h)
|
liftIO $ clearArea foreground (GeglRectangle 0 0 w h)
|
||||||
maybe (return ()) (\(x, y) ->
|
maybe (return ()) (\(x, y) ->
|
||||||
drawRect'
|
drawRect
|
||||||
(nodeGraph M.! "nop")
|
(nodeGraph M.! "nop")
|
||||||
(G.RGBA 1 0 0 0.5)
|
(G.RGBA 1 0 0 0.5)
|
||||||
(Fill)
|
(Fill)
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
-- | Module for drawing primitives
|
-- | Module for drawing primitives
|
||||||
module Affection.Draw
|
module Affection.Draw
|
||||||
(
|
( drawRect
|
||||||
-- drawRect
|
|
||||||
drawRect'
|
|
||||||
-- , clear
|
-- , clear
|
||||||
, handleDrawRequest
|
, handleDrawRequest
|
||||||
, invalidateDrawRequest
|
, invalidateDrawRequest
|
||||||
|
@ -30,53 +28,14 @@ import qualified GEGL as G
|
||||||
|
|
||||||
import Debug.Trace
|
import Debug.Trace
|
||||||
|
|
||||||
-- | Draw a rectangle on target buffer
|
drawRect
|
||||||
-- 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'
|
|
||||||
:: G.GeglNode -- ^ Target Node
|
:: G.GeglNode -- ^ Target Node
|
||||||
-> G.Color -- ^ Color to draw in
|
-> G.Color -- ^ Color to draw in
|
||||||
-> DrawType -- ^ Draw type
|
-> DrawType -- ^ Draw type
|
||||||
-> G.GeglRectangle -- ^ Dimensions of Rectangle
|
-> G.GeglRectangle -- ^ Dimensions of Rectangle
|
||||||
-> G.GeglBuffer -- ^ Final Buffer
|
-> G.GeglBuffer -- ^ Final Buffer
|
||||||
-> Affection us ()
|
-> Affection us ()
|
||||||
drawRect' node color Fill rect@GeglRectangle{..} buf = do
|
drawRect node color Fill rect@GeglRectangle{..} buf = do
|
||||||
ad <- get
|
ad <- get
|
||||||
tempRoot <- liftIO $ G.gegl_node_new
|
tempRoot <- liftIO $ G.gegl_node_new
|
||||||
opNode <- liftIO $ G.gegl_node_new_child tempRoot $ G.Operation "gegl:rectangle"
|
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
|
{ 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
|
-- | function for handling 'DrawRequest's and updating the output
|
||||||
handleDrawRequest
|
handleDrawRequest
|
||||||
:: Ptr a -- ^ Pixel buffer to blit to
|
:: Ptr a -- ^ Pixel buffer to blit to
|
||||||
|
@ -233,12 +168,6 @@ unsafeColorize col =
|
||||||
, G.CVdouble $ CDouble $ a
|
, 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
|
-- | Clear a specified area of a buffer from all data
|
||||||
clearArea
|
clearArea
|
||||||
:: G.GeglBuffer -- ^ Target buffer
|
:: G.GeglBuffer -- ^ Target buffer
|
||||||
|
|
Loading…
Reference in a new issue