Skip to content

Commit

Permalink
cleaned up step positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrJustyna committed Apr 1, 2024
1 parent fe40c4c commit deada6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions HelloWorld.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,25 @@ stepHeight = cellHeight *stepHeightToCellHeightRatio
shortestDistanceBetweenSteps :: Double
shortestDistanceBetweenSteps = cellHeight * (1.0 - stepHeightToCellHeightRatio)

connectionToPreviousStep :: Double -> Double -> Diagram B
connectionToPreviousStep x y =
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))

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

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 <>
fromOffsets [V2 0 y] <>
fromOffsets [V2 x 0] # translate (r2 (0, y))
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] <>
fromOffsets [V2 x 0] # translate (r2 (0, y))
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 :: Main.Name -> Double -> Double -> Diagram B
decisionShape name x y = text name # fontSize (local 0.1) # light # font "courier" <>
Expand All @@ -67,8 +71,8 @@ decisionShape name x y = text name # fontSize (local 0.1) # light # font "courie
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] <>
fromOffsets [V2 x 0] # translate (r2 (0, y)) <>
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)) <>
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))

Expand Down
Loading

0 comments on commit deada6a

Please sign in to comment.