Skip to content

Commit

Permalink
added some colour
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrJustyna committed Apr 22, 2024
1 parent ff83972 commit d284711
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 25 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
77 changes: 53 additions & 24 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Main where

import qualified Data.Colour.SRGB

import qualified Data.Map

import qualified Diagrams.Backend.SVG.CmdLine
Expand Down Expand Up @@ -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 ->
Expand All @@ -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 ->
Expand All @@ -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 ->
Expand All @@ -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
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
1 change: 1 addition & 0 deletions drakon-renderer.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ executable drakon-renderer
diagrams,
diagrams-lib,
diagrams-svg,
colour,
containers

hs-source-dirs: app
Expand Down
Loading

0 comments on commit d284711

Please sign in to comment.