diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2011-06-25 18:33:43 +0100 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2011-06-25 18:39:53 +0100 |
commit | 14e9d7b6a78a954ddbd697f01c7b98bb4ef6f571 (patch) | |
tree | cbf330e8ba6753c817a78ce0c4bc00990a2151c2 | |
parent | 14c993caa05fb2e1f181dac7e190e6026a53a2d8 (diff) |
WIP: automate drawing icondraw-icon
-rw-r--r-- | Bustle/Diagram.hs | 19 | ||||
-rw-r--r-- | Bustle/DrawIcon.hs | 41 | ||||
-rw-r--r-- | bustle.cabal | 5 |
3 files changed, 60 insertions, 5 deletions
diff --git a/Bustle/Diagram.hs b/Bustle/Diagram.hs index eb0eadc..03a6b04 100644 --- a/Bustle/Diagram.hs +++ b/Bustle/Diagram.hs @@ -43,6 +43,9 @@ module Bustle.Diagram , topLeftJustifyDiagram , drawDiagram , drawRegion + + -- Only for the icon drawing code + , drawArcCurve ) where @@ -370,11 +373,10 @@ drawSignalArrow e left right y = do arrowHead True stroke -drawArc :: Double -> Double -> Double -> Double - -> Double -> Double -> Double -> Double - -> String - -> Render () -drawArc cx cy dx dy x1 y1 x2 y2 cap = saved $ do +drawArcCurve :: Double -> Double -> Double -> Double + -> Double -> Double -> Double -> Double + -> Render () +drawArcCurve cx cy dx dy x1 y1 x2 y2 = saved $ do setSourceRGB 0.4 0.7 0.4 setDash [3, 3] 0 @@ -382,6 +384,13 @@ drawArc cx cy dx dy x1 y1 x2 y2 cap = saved $ do curveTo cx cy dx dy x2 y2 stroke +drawArc :: Double -> Double -> Double -> Double + -> Double -> Double -> Double -> Double + -> String + -> Render () +drawArc cx cy dx dy x1 y1 x2 y2 cap = saved $ do + drawArcCurve cx cy dx dy x1 y1 x2 y2 + setSourceRGB 0 0 0 l <- mkLayout cap EllipsizeNone AlignLeft (PangoRectangle _ _ textWidth _, _) <- liftIO $ layoutGetExtents l diff --git a/Bustle/DrawIcon.hs b/Bustle/DrawIcon.hs new file mode 100644 index 0000000..a1e21f5 --- /dev/null +++ b/Bustle/DrawIcon.hs @@ -0,0 +1,41 @@ +module Main where + +import Graphics.Rendering.Cairo +import Bustle.Diagram + +width, height :: Num a => a +width = 64 +height = width + +halfwayAcross = width / 2 +halfwayDown = height / 2 + +scaleFactor = 4 + +main = do + withImageSurface FormatARGB32 (width * scaleFactor) (height * scaleFactor) $ \surface -> do + renderWith surface $ do + scale 3.8 3.8 + + --setSourceRGBA 1 1 1 0 + --rectangle 0 0 width height + --Graphics.Rendering.Cairo.fill + + drawDiagram False [SignalArrow 0 halfwayAcross width halfwayDown] + drawArcCurve 0 0 width 0 0 halfwayDown width halfwayDown + + -- setSourceRGB 0 0 0 + -- shape $ SignalArrow (x1 - 20) x (x2 + 20) t + -- signalArrow 25 22 29 33 + + -- setSourceRGB 0.4 0.7 0.4 + -- setDash [6, 3] 0 + + -- moveTo 2 33 + -- curveTo 2 2 49 2 49 33 + -- stroke + + -- setSourceRGB 0 0 0 + -- setDash [] 0 + + surfaceWriteToPNG surface "bustle-256.png" diff --git a/bustle.cabal b/bustle.cabal index 1709c2a..2f043d4 100644 --- a/bustle.cabal +++ b/bustle.cabal @@ -59,3 +59,8 @@ Executable bustle-dot Other-modules: Bustle.Parser, Bustle.Types Build-Depends: haskell98, base >= 4 && < 5, containers, parsec Ghc-options: -Wall -fno-warn-unused-imports -fno-warn-unused-do-bind + +-- Heh, heh. This gets us an executable which isn't installed. +Test-Suite bustle-draw-icon + Type: exitcode-stdio-1.0 + Main-is: Bustle/DrawIcon.hs |