Skip to content

Commit

Permalink
removed the named function, cleaned up the code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrJustyna committed Apr 1, 2024
1 parent deada6a commit 97cf015
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
31 changes: 15 additions & 16 deletions HelloWorld.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,31 @@ connectionToPreviousStep x y =

startShape :: Main.Name -> Diagram B
startShape name = text (name ++ ": start") # fontSize (local 0.1) # light # font "courier" <>
roundedRect stepWidth stepHeight 0.5 # showOrigin # named name
roundedRect stepWidth stepHeight 0.5 # showOrigin

endShape :: Main.Name -> Double -> Double -> Diagram B
endShape name x y = text (name ++ ": end") # fontSize (local 0.1) # thinWeight # font "courier" <>
roundedRect stepWidth stepHeight 0.5 # showOrigin # named name <>
roundedRect stepWidth stepHeight 0.5 # showOrigin <>
connectionToPreviousStep x y

commandShape :: Main.Name -> Double -> Double -> Diagram B
commandShape name x y = text name # fontSize (local 0.1) # light # font "courier" <>
rect stepWidth stepHeight # showOrigin # named name <>
fromOffsets [V2 0 (y - (if (abs x) > 0 then stepHeight * 0.5 else stepHeight))] # translate (r2 (0, stepHeight * 0.5)) <>
fromOffsets [V2 (if (abs x > 0) then (x + (stepWidth * 0.5)) else 0) 0] # translate (r2 (0, y))
rect stepWidth stepHeight # showOrigin <>
connectionToPreviousStep x y

decisionShape :: Main.Name -> Double -> Double -> Diagram B
decisionShape name x y = text name # fontSize (local 0.1) # light # font "courier" <>
fromOffsets
[V2 (-0.1) (stepHeight * 0.5),
V2 0.1 (stepHeight * 0.5),
V2 (stepWidth - 0.1 - 0.1) 0.0,
V2 0.1 (stepHeight * (-0.5)),
V2 (-0.1) (stepHeight * (-0.5)),
V2 ((stepWidth - 0.1 - 0.1) * (-1.0)) 0.0] # translate (r2 (((stepWidth - 0.1 - 0.1) * (-0.5)), (-0.2))) # showOrigin # named name <>
fromOffsets [V2 0 (y - (if (abs x) > 0 then stepHeight * 0.5 else stepHeight))] # translate (r2 (0, stepHeight * 0.5)) <>
fromOffsets [V2 (if (abs x > 0) then (x + (stepWidth * 0.5)) else 0) 0] # translate (r2 (0, y)) <>
decisionShape name x y =
text name # fontSize (local 0.1) # light # font "courier" <>
text "yes" # fontSize (local 0.1) # light # font "courier" # translate (r2 (stepWidth * (-0.1), stepHeight * (-0.7))) <>
text "no" # fontSize (local 0.1) # light # font "courier" # translate (r2 (stepWidth * 0.6, stepHeight * 0.15))
text "no" # fontSize (local 0.1) # light # font "courier" # translate (r2 (stepWidth * 0.6, stepHeight * 0.15)) <>
fromOffsets
[V2 (-0.1) (stepHeight * 0.5),
V2 0.1 (stepHeight * 0.5),
V2 (stepWidth - 0.1 - 0.1) 0.0,
V2 0.1 (stepHeight * (-0.5)),
V2 (-0.1) (stepHeight * (-0.5)),
V2 ((stepWidth - 0.1 - 0.1) * (-1.0)) 0.0] # translate (r2 (((stepWidth - 0.1 - 0.1) * (-0.5)), (-0.2))) # showOrigin <>
connectionToPreviousStep x y

uniqueName :: Double -> Double -> Main.Name
uniqueName x y = "x" ++ (show x) ++ "y" ++ (show y)
Expand Down
Loading

0 comments on commit 97cf015

Please sign in to comment.