diff --git a/README.md b/README.md index c3a5b9b..8548441 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ Haskell drakon renderer. * [drakon](https://drakonhub.com/read/docs) * [diagrams](https://archives.haskell.org/projects.haskell.org/diagrams/doc/quickstart.html#introduction) * [diagrams - user manual](https://archives.haskell.org/projects.haskell.org/diagrams/doc/manual.html) +* [colours](https://www.colourlovers.com) + * [you will be free](https://www.colourlovers.com/palette/452030/you_will_be_free) * useful haskell modules: * [GHC.Data.Graph.Directed](https://hackage.haskell.org/package/ghc-9.4.7/docs/GHC-Data-Graph-Directed.html) * [GHC.Utils.Outputable](https://hackage.haskell.org/package/ghc-9.4.7/docs/GHC-Utils-Outputable.html) \ No newline at end of file diff --git a/app/Main.hs b/app/Main.hs index c3f1f4e..5241c41 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,5 +1,7 @@ module Main where +import qualified Data.Colour.SRGB + import qualified Data.Map import qualified Diagrams.Backend.SVG.CmdLine @@ -382,12 +384,22 @@ titleShape :: String -> Diagrams.Prelude.Diagram Diagrams.Backend.SVG.CmdLine.B titleShape x = do + let baseShape = + Diagrams.Prelude.roundedRect iconWidth iconHeight 0.5 + Diagrams.Prelude.# + Diagrams.Prelude.fc (Data.Colour.SRGB.sRGB (236.0/255.0) (249.0/255.0) (254.0/255.0)) + +-- (text x 0.0 0.0 +-- Diagrams.Prelude.=== +-- (text x 0.0 0.0 <> Diagrams.Prelude.strutY (0.05 * 2.0))) +-- <> shape + let shape = if troubleshootingMode - then Diagrams.Prelude.showOrigin $ Diagrams.Prelude.roundedRect iconWidth iconHeight 0.5 - else Diagrams.Prelude.roundedRect iconWidth iconHeight 0.5 + then Diagrams.Prelude.showOrigin baseShape + else baseShape - shape - <> text x 0.0 0.0 + (text x 0.0 0.0) + <> shape actionShape :: Double -> @@ -398,13 +410,18 @@ actionShape parentIconVectorX parentIconVectorY x = do + let baseShape = + Diagrams.Prelude.rect iconWidth iconHeight + Diagrams.Prelude.# + Diagrams.Prelude.fc (Data.Colour.SRGB.sRGB (220.0/255.0) (232.0/255.0) (235.0/255.0)) + let shape = if troubleshootingMode - then Diagrams.Prelude.showOrigin $ Diagrams.Prelude.rect iconWidth iconHeight - else Diagrams.Prelude.rect iconWidth iconHeight + then Diagrams.Prelude.showOrigin $ baseShape + else baseShape - shape - <> connectionToParentIcon parentIconVectorX parentIconVectorY - <> text x 0.0 0.0 + (text x 0.0 0.0) + <> shape + <> connectionToParentIcon parentIconVectorX parentIconVectorY questionShape :: Double -> @@ -424,21 +441,23 @@ questionShape Diagrams.Prelude.V2 (-0.1) (iconHeight * (-0.5)), Diagrams.Prelude.V2 ((iconWidth - 0.1 - 0.1) * (-1.0)) 0.0] Diagrams.Prelude.# + Diagrams.Prelude.closeLine + Diagrams.Prelude.# + Diagrams.Prelude.strokeLoop + Diagrams.Prelude.# + Diagrams.Prelude.fc (Data.Colour.SRGB.sRGB (203.0/255.0) (219.0/255.0) (224.0/255.0)) + Diagrams.Prelude.# Diagrams.Prelude.translate (Diagrams.Prelude.r2 ((iconWidth - 0.1 - 0.1) * (-0.5), -0.2)) let shape = if troubleshootingMode then Diagrams.Prelude.showOrigin baseShape else baseShape - shape - <> - connectionToParentIcon parentIconVectorX parentIconVectorY - <> - text x 0.0 0.0 - <> - text "yes" (iconWidth * (-0.1)) (iconHeight * (-0.7)) - <> - text "no" (iconWidth * 0.55) (iconHeight * 0.15) + (text x 0.0 0.0) + <> text "yes" (iconWidth * (-0.1)) (iconHeight * (-0.7)) + <> text "no" (iconWidth * 0.55) (iconHeight * 0.15) + <> shape + <> connectionToParentIcon parentIconVectorX parentIconVectorY endShape :: Double -> @@ -449,16 +468,26 @@ endShape parentIconVectorX parentIconVectorY x = do + let baseShape = + Diagrams.Prelude.roundedRect iconWidth iconHeight 0.5 + Diagrams.Prelude.# + Diagrams.Prelude.fc (Data.Colour.SRGB.sRGB (190.0/255.0) (210.0/255.0) (217.0/255.0)) + let shape = if troubleshootingMode - then Diagrams.Prelude.showOrigin $ Diagrams.Prelude.roundedRect iconWidth iconHeight 0.5 - else Diagrams.Prelude.roundedRect iconWidth iconHeight 0.5 + then Diagrams.Prelude.showOrigin $ baseShape + else baseShape - shape - <> connectionToParentIcon parentIconVectorX parentIconVectorY - <> text x 0.0 0.0 + (text x 0.0 0.0) + <> shape + <> connectionToParentIcon parentIconVectorX parentIconVectorY main :: IO () main = do GHC.Utils.Outputable.printSDocLn GHC.Utils.Outputable.defaultSDocContext GHC.Utils.Ppr.LeftMode System.IO.stdout $ GHC.Utils.Outputable.ppr graph - Diagrams.Backend.SVG.CmdLine.mainWith $ Diagrams.Prelude.position visualGraph Diagrams.Prelude.# Diagrams.Prelude.lw Diagrams.Prelude.veryThin \ No newline at end of file + Diagrams.Backend.SVG.CmdLine.mainWith $ + Diagrams.Prelude.position visualGraph + Diagrams.Prelude.# + Diagrams.Prelude.bg (Data.Colour.SRGB.sRGB (247.0/255.0) (249.0/255.0) (254.0/255.0)) + Diagrams.Prelude.# + Diagrams.Prelude.lw Diagrams.Prelude.veryThin \ No newline at end of file diff --git a/drakon-renderer.cabal b/drakon-renderer.cabal index 40c47b8..07b8706 100644 --- a/drakon-renderer.cabal +++ b/drakon-renderer.cabal @@ -65,6 +65,7 @@ executable drakon-renderer diagrams, diagrams-lib, diagrams-svg, + colour, containers hs-source-dirs: app diff --git a/hello-world.svg b/hello-world.svg index ecadf6a..c58748f 100644 --- a/hello-world.svg +++ b/hello-world.svg @@ -1,3 +1,3 @@ end 4 | rendering order: 12 | max width: 6.0end 3 | rendering order: 11 | max width: 4.0action 4 | rendering order: 10 | max width: 4.0noyesquestion 3 | rendering order: 9 | max width: 4.0end 2 | rendering order: 8 | max width: 2.0action 3 | rendering order: 7 | max width: 2.0end 1 | rendering order: 6 | max width: 0.0action 2 | rendering order: 5 | max width: 0.0noyesquestion 2 | rendering order: 4 | max width: 0.0action 1 | rendering order: 3 | max width: 0.0noyesquestion 1 | rendering order: 2 | max width: 0.0start | rendering order: 1 | max width: 0.0 \ No newline at end of file + "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">end 4 | rendering order: 12 | max width: 6.0end 3 | rendering order: 11 | max width: 4.0action 4 | rendering order: 10 | max width: 4.0noyesquestion 3 | rendering order: 9 | max width: 4.0end 2 | rendering order: 8 | max width: 2.0action 3 | rendering order: 7 | max width: 2.0end 1 | rendering order: 6 | max width: 0.0action 2 | rendering order: 5 | max width: 0.0noyesquestion 2 | rendering order: 4 | max width: 0.0action 1 | rendering order: 3 | max width: 0.0noyesquestion 1 | rendering order: 2 | max width: 0.0start | rendering order: 1 | max width: 0.0 \ No newline at end of file