ghci-diagrams 0.1 → 0.1.1
raw patch · 2 files changed
+29/−10 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- DrawDiagrams.hs +25/−8
- ghci-diagrams.cabal +4/−2
DrawDiagrams.hs view
@@ -8,6 +8,9 @@ import Diagrams +import Control.Concurrent+import Control.Concurrent.MVar+ import Graphics.UI.Gtk import Graphics.Rendering.Cairo ( Render, liftIO ) import Graphics.Rendering.Diagrams.Engine ( render )@@ -24,22 +27,36 @@ initGUI dialog <- dialogNew windowSetKeepAbove dialog True+ windowSetDefaultSize dialog w h set dialog [ windowWindowPosition := WinPosCenter ] dialogAddButton dialog stockClose ResponseClose contain <- dialogGetUpper dialog canvas <- drawingAreaNew- canvas `onSizeRequest` return (Requisition w h)- boxPackStartDefaults contain canvas+ af <- aspectFrameNew 0.5 0.5 (Just 1.6)+ canvas `onSizeRequest` return (Requisition 160 100)+ containerAdd af canvas+ boxPackStartDefaults contain af canvas `on` exposeEvent $ tryEvent $ liftIO $ do win <- widgetGetDrawWindow canvas- renderWithDrawable win $+ (w, h) <- drawableGetSize win+ let (w', h') = (fromIntegral w, fromIntegral h)+ let sc = w' / 32+ renderWithDrawable win $ do flip runDiaRenderM defaultDiaRenderEnv $ render $- (rect (fromIntegral w) (fromIntegral h) `fill` white `strokeWidth` 0 - <|> scaleY (-1) dia `scale` 20)- `move` (fromIntegral w/2, fromIntegral h/2)+ (rect w' h' `fill` white `strokeWidth` 0 + <|> scaleY (-1) dia `scale` sc `strokeWidth` (0.05*sc))+ `move` (w'/2, h'/2) - widgetShow canvas- dialogRun dialog+ s <- newEmptyMVar+ tid <- forkIO $ do + _ <- getChar+ putMVar s ()+ forkIO $ do+ widgetShowAll dialog+ dialogRun dialog+ putMVar s ()+ _ <- takeMVar s+ killThread tid widgetDestroy dialog flush
ghci-diagrams.cabal view
@@ -1,12 +1,14 @@ name: ghci-diagrams-version: 0.1+version: 0.1.1 category: Graphics synopsis: Display simple diagrams from ghci description: This library provides a simple 2D graphics environment which is used in our beginner's Haskell course at ELTE University in Budapest. .- Example> draw $ circle 3+ Example> draw $ circle 10 `fill` lightblue+ .+ Changes since version 0.1: resizeable diagram, easier exit stability: alpha license: BSD3 license-file: LICENSE