Created
January 21, 2012 00:10
-
-
Save wavewave/1650370 to your computer and use it in GitHub Desktop.
gtk2hs drawingArea
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Graphics.UI.Gtk | |
| import Graphics.Rendering.Cairo | |
| import Control.Monad.Trans | |
| main :: IO () | |
| main = do | |
| initGUI | |
| window <- windowNew | |
| vbox <- vBoxNew False 0 | |
| canvas <- drawingAreaNew | |
| set canvas [ widgetWidthRequest := 400 | |
| , widgetHeightRequest := 400 ] | |
| boxPackStart vbox canvas PackNatural 0 | |
| containerAdd window vbox | |
| canvas `on` exposeEvent $ tryEvent $ do | |
| win <- liftIO $ widgetGetDrawWindow canvas | |
| liftIO . renderWithDrawable win $ do | |
| setSourceRGBA 0 0 0 1 | |
| setLineWidth 1.0 | |
| moveTo 100 100 | |
| lineTo 200 200 | |
| stroke | |
| window `on` deleteEvent $ tryEvent $ do | |
| liftIO $ mainQuit | |
| widgetShowAll window | |
| mainGUI | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment