Skip to content

Commit

Permalink
all shape rendering methods accept lists of vectors to parent coordin…
Browse files Browse the repository at this point in the history
…ates
  • Loading branch information
PiotrJustyna committed Apr 25, 2024
1 parent 36daa5c commit 54e7f94
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,13 @@ connectionToParentIcon x y =
connectionToParentIcons ::
[(Double, Double)] ->
Diagrams.Prelude.Diagram Diagrams.Backend.SVG.CmdLine.B
connectionToParentIcons parentIconOriginVectors =
connectionToParentIcons =
foldl
(\acc (vectorX, vectorY) ->
acc
<>
connectionToParentIcon vectorX vectorY) -- translate to 0,0 before next connection starts
connectionToParentIcon vectorX vectorY)
mempty
parentIconOriginVectors

correctShape ::
IconType ->
Expand All @@ -401,11 +400,11 @@ correctShape ::
correctShape Title _ _ titleIconText renderingOrder maxWidth =
titleShape titleIconText renderingOrder maxWidth
correctShape End parentIconVectorX parentIconVectorY endIconText renderingOrder maxWidth =
endShape parentIconVectorX parentIconVectorY endIconText renderingOrder maxWidth
endShape [(parentIconVectorX, parentIconVectorY)] endIconText renderingOrder maxWidth
correctShape Question parentIconVectorX parentIconVectorY questionIconText renderingOrder maxWidth =
questionShape parentIconVectorX parentIconVectorY questionIconText renderingOrder maxWidth
questionShape [(parentIconVectorX, parentIconVectorY)] questionIconText renderingOrder maxWidth
correctShape Action parentIconVectorX parentIconVectorY actionIconText renderingOrder maxWidth =
actionShape parentIconVectorX parentIconVectorY actionIconText renderingOrder maxWidth
actionShape [(parentIconVectorX, parentIconVectorY)] actionIconText renderingOrder maxWidth

text ::
String ->
Expand Down Expand Up @@ -464,15 +463,13 @@ titleShape
<> shape

actionShape ::
Double ->
Double ->
[(Double, Double)] ->
String ->
Int ->
Double ->
Diagrams.Prelude.Diagram Diagrams.Backend.SVG.CmdLine.B
actionShape
parentIconVectorX
parentIconVectorY
vectorsToParentCoordinates
actionIconText
renderingOrder
maxWidth = do
Expand All @@ -498,30 +495,28 @@ actionShape
Diagrams.Prelude.#
Diagrams.Prelude.translate (Diagrams.Prelude.r2 (0, fontSize))
<> shape
<> connectionToParentIcon parentIconVectorX parentIconVectorY
<> connectionToParentIcons vectorsToParentCoordinates
Diagrams.Prelude.#
Diagrams.Prelude.lc lineColour
Diagrams.Prelude.#
Diagrams.Prelude.lw Diagrams.Prelude.ultraThin
else
text actionIconText 0.0 0.0
<> shape
<> connectionToParentIcon parentIconVectorX parentIconVectorY
<> connectionToParentIcons vectorsToParentCoordinates
Diagrams.Prelude.#
Diagrams.Prelude.lc lineColour
Diagrams.Prelude.#
Diagrams.Prelude.lw Diagrams.Prelude.ultraThin

questionShape ::
Double ->
Double ->
[(Double, Double)] ->
String ->
Int ->
Double ->
Diagrams.Prelude.Diagram Diagrams.Backend.SVG.CmdLine.B
questionShape
parentIconVectorX
parentIconVectorY
vectorsToParentCoordinates
questionIconText
renderingOrder
maxWidth = do
Expand Down Expand Up @@ -561,7 +556,7 @@ questionShape
<> text "yes" (iconWidth * (-0.1)) (iconHeight * (-0.7))
<> text "no" (iconWidth * 0.55) (iconHeight * 0.15)
<> shape
<> connectionToParentIcon parentIconVectorX parentIconVectorY
<> connectionToParentIcons vectorsToParentCoordinates
Diagrams.Prelude.#
Diagrams.Prelude.lc lineColour
Diagrams.Prelude.#
Expand All @@ -571,22 +566,20 @@ questionShape
<> text "yes" (iconWidth * (-0.1)) (iconHeight * (-0.7))
<> text "no" (iconWidth * 0.55) (iconHeight * 0.15)
<> shape
<> connectionToParentIcon parentIconVectorX parentIconVectorY
<> connectionToParentIcons vectorsToParentCoordinates
Diagrams.Prelude.#
Diagrams.Prelude.lc lineColour
Diagrams.Prelude.#
Diagrams.Prelude.lw Diagrams.Prelude.ultraThin

endShape ::
Double ->
Double ->
[(Double, Double)] ->
String ->
Int ->
Double ->
Diagrams.Prelude.Diagram Diagrams.Backend.SVG.CmdLine.B
endShape
parentIconVectorX
parentIconVectorY
vectorsToParentCoordinates
endIconText
renderingOrder
maxWidth = do
Expand All @@ -612,15 +605,15 @@ endShape
Diagrams.Prelude.#
Diagrams.Prelude.translate (Diagrams.Prelude.r2 (0, fontSize))
<> shape
<> connectionToParentIcons [(parentIconVectorX, parentIconVectorY)]
<> connectionToParentIcons vectorsToParentCoordinates
Diagrams.Prelude.#
Diagrams.Prelude.lc lineColour
Diagrams.Prelude.#
Diagrams.Prelude.lw Diagrams.Prelude.ultraThin
else
text endIconText 0.0 0.0
<> shape
<> connectionToParentIcon parentIconVectorX parentIconVectorY
<> connectionToParentIcons vectorsToParentCoordinates
Diagrams.Prelude.#
Diagrams.Prelude.lc lineColour
Diagrams.Prelude.#
Expand Down

0 comments on commit 54e7f94

Please sign in to comment.