port example02 to props

This commit is contained in:
Astro 2017-03-17 00:20:00 +01:00
parent a737e2863c
commit ac9a9e3bdc

View file

@ -34,31 +34,31 @@ load _ = do
traceM "loading" traceM "loading"
root <- G.gegl_node_new root <- G.gegl_node_new
traceM "new root node" traceM "new root node"
checkerboard <- G.gegl_node_new_child root $ G.checkerboardOperation checkerboard <- G.gegl_node_new_child root $ G.checkerboardOperation $
[ G.Property "color1" $ G.PropertyColor $ G.RGBA 0.4 0.4 0.4 1 props $ do
, G.Property "color2" $ G.PropertyColor $ G.RGBA 0.6 0.6 0.6 1 prop "color1" $ G.RGBA 0.4 0.4 0.4 1
] prop "color2" $ G.RGBA 0.6 0.6 0.6 1
traceM "checkerboard" traceM "checkerboard"
over <- G.gegl_node_new_child root G.defaultOverOperation over <- G.gegl_node_new_child root G.defaultOverOperation
traceM "over" traceM "over"
buffer <- G.gegl_buffer_new (Just $ G.GeglRectangle 0 0 800 600) =<< buffer <- G.gegl_buffer_new (Just $ G.GeglRectangle 0 0 800 600) =<<
B.babl_format (B.PixelFormat B.RGBA B.CFfloat) B.babl_format (B.PixelFormat B.RGBA B.CFfloat)
sink <- G.gegl_node_new_child root $ G.Operation "gegl:copy-buffer" sink <- G.gegl_node_new_child root $ G.Operation "gegl:copy-buffer" $
[ G.Property "buffer" $ G.PropertyBuffer buffer props $
] prop "buffer" buffer
traceM "buffer-sink" traceM "buffer-sink"
rect <- G.gegl_node_new_child root $ G.Operation "gegl:rectangle" rect <- G.gegl_node_new_child root $ G.Operation "gegl:rectangle" $
[ G.Property "x" $ G.PropertyDouble 0 props $ do
, G.Property "y" $ G.PropertyDouble 0 prop "x" (0::Double)
, G.Property "width" $ G.PropertyDouble 20 prop "y" (0::Double)
, G.Property "height" $ G.PropertyDouble 20 prop "width" (20::Double)
, G.Property "color" $ G.PropertyColor $ G.RGBA 1 0 0 0.5 prop "height" (20::Double)
] prop "color" $ G.RGBA 1 0 0 0.5
traceM "rect" traceM "rect"
crop <- G.gegl_node_new_child root $ G.Operation "gegl:crop" crop <- G.gegl_node_new_child root $ G.Operation "gegl:crop" $
[ G.Property "width" $ G.PropertyDouble 800 props $ do
, G.Property "height" $ G.PropertyDouble 600 prop "width" (800::Double)
] prop "height" (600::Double)
G.gegl_node_link_many [checkerboard, over, crop, sink] G.gegl_node_link_many [checkerboard, over, crop, sink]
_ <- G.gegl_node_connect_to rect "output" over "aux" _ <- G.gegl_node_connect_to rect "output" over "aux"
traceM "connections made" traceM "connections made"
@ -103,10 +103,10 @@ update = do
handle (SDL.MouseMotionEvent dat) = do handle (SDL.MouseMotionEvent dat) = do
let (SDL.P (SDL.V2 x y)) = SDL.mouseMotionEventPos dat let (SDL.P (SDL.V2 x y)) = SDL.mouseMotionEventPos dat
ud <- getAffection ud <- getAffection
liftIO $ G.gegl_node_set (nodeGraph ud M.! "rect") $ G.Operation "" liftIO $ G.gegl_node_set (nodeGraph ud M.! "rect") $ G.Operation "" $
[ G.Property "x" $ G.PropertyDouble $ fromIntegral (x - 10) props $ do
, G.Property "y" $ G.PropertyDouble $ fromIntegral (y - 10) prop "x" (fromIntegral (x - 10) :: Double)
] prop "y" $ (fromIntegral (y - 10) :: Double)
handle (SDL.WindowClosedEvent _) = do handle (SDL.WindowClosedEvent _) = do
traceM "seeya!" traceM "seeya!"