Skip to content

Commit

Permalink
more refined rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrJustyna committed Apr 22, 2024
1 parent d284711 commit 1a0da84
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,12 @@ visualGraph = do
let startingDepth = 0.0
let firstChildIconDepth = startingDepth + (-1.0) * cellHeight
let Icon { iconText = titleIconText, iconType = _ } = payload titleIcon
let text = conditionalRenderingSuffix titleIconText renderingOrder startingWidth troubleshootingMode
let conditionalText = conditionalRenderingSuffix titleIconText renderingOrder startingWidth troubleshootingMode
let titleIconDependenciesKeys = dependencies titleIcon
let titleIconDependencies = iconsWithKeys titleIconDependenciesKeys
let (_, _, childSubgraphVisualData) = visualSubgraph titleIconDependencies (renderingOrder + 1) startingWidth firstChildIconDepth startingWidth startingDepth

(Diagrams.Prelude.p2 (0.0, 0.0), titleShape text) : childSubgraphVisualData
(Diagrams.Prelude.p2 (0.0, 0.0), titleShape conditionalText) : childSubgraphVisualData

visualSubgraph ::
[GHC.Data.Graph.Directed.Node Int Icon] ->
Expand Down Expand Up @@ -356,7 +356,7 @@ correctShape ::
Double ->
String ->
Diagrams.Prelude.Diagram Diagrams.Backend.SVG.CmdLine.B
correctShape Title parentIconVectorX parentIconVectorY x = titleShape x
correctShape Title _ _ x = titleShape x
correctShape End parentIconVectorX parentIconVectorY x = endShape parentIconVectorX parentIconVectorY x
correctShape Question parentIconVectorX parentIconVectorY x = questionShape parentIconVectorX parentIconVectorY x
correctShape Action parentIconVectorX parentIconVectorY x = actionShape parentIconVectorX parentIconVectorY x
Expand Down Expand Up @@ -388,6 +388,8 @@ titleShape x = do
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))
Diagrams.Prelude.#
Diagrams.Prelude.lw Diagrams.Prelude.none

-- (text x 0.0 0.0
-- Diagrams.Prelude.===
Expand All @@ -414,14 +416,16 @@ actionShape
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))
Diagrams.Prelude.#
Diagrams.Prelude.lw Diagrams.Prelude.none

let shape = if troubleshootingMode
then Diagrams.Prelude.showOrigin $ baseShape
else baseShape

(text x 0.0 0.0)
<> shape
<> connectionToParentIcon parentIconVectorX parentIconVectorY
<> (connectionToParentIcon parentIconVectorX parentIconVectorY Diagrams.Prelude.# Diagrams.Prelude.lw Diagrams.Prelude.ultraThin)

questionShape ::
Double ->
Expand All @@ -447,6 +451,8 @@ questionShape
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.lw Diagrams.Prelude.none
Diagrams.Prelude.#
Diagrams.Prelude.translate (Diagrams.Prelude.r2 ((iconWidth - 0.1 - 0.1) * (-0.5), -0.2))

let shape = if troubleshootingMode
Expand All @@ -457,7 +463,7 @@ questionShape
<> text "yes" (iconWidth * (-0.1)) (iconHeight * (-0.7))
<> text "no" (iconWidth * 0.55) (iconHeight * 0.15)
<> shape
<> connectionToParentIcon parentIconVectorX parentIconVectorY
<> (connectionToParentIcon parentIconVectorX parentIconVectorY Diagrams.Prelude.# Diagrams.Prelude.lw Diagrams.Prelude.ultraThin)

endShape ::
Double ->
Expand All @@ -472,14 +478,16 @@ endShape
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))
Diagrams.Prelude.#
Diagrams.Prelude.lw Diagrams.Prelude.none

let shape = if troubleshootingMode
then Diagrams.Prelude.showOrigin $ baseShape
else baseShape

(text x 0.0 0.0)
<> shape
<> connectionToParentIcon parentIconVectorX parentIconVectorY
<> (connectionToParentIcon parentIconVectorX parentIconVectorY Diagrams.Prelude.# Diagrams.Prelude.lw Diagrams.Prelude.ultraThin)

main ::
IO ()
Expand All @@ -490,4 +498,4 @@ main = do
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
Diagrams.Prelude.lw Diagrams.Prelude.none
Loading

0 comments on commit 1a0da84

Please sign in to comment.