aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2020-09-05 21:22:39 +0100
committerYann Herklotz <git@yannherklotz.com>2020-09-05 21:22:39 +0100
commit8a5b180c740bff215f9cd17001f2f21749c8e5cc (patch)
treea6524fa5b70d813df82fed4d8a88dafbb5e4bfaf
parentbf67d3573d25f34c963c43395fc98a03207fd751 (diff)
downloadalluvial-hs-8a5b180c740bff215f9cd17001f2f21749c8e5cc.tar.gz
alluvial-hs-8a5b180c740bff215f9cd17001f2f21749c8e5cc.zip
Fix bug during printing
-rw-r--r--src/Main.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Main.hs b/src/Main.hs
index ed345dc..b1d82c0 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -39,8 +39,8 @@ inBetween :: Coord -> Coord -> Coord
inBetween (Coord x1 y1) (Coord x2 y2) =
Coord ((x1 + x2) / 2) ((y1 + y2) / 2)
-drawArrow :: Double -> Double -> (Double, String) -> Ribbon -> (Double, String)
-drawArrow ratio len (start, s) (Ribbon b i) =
+drawArrow :: Double -> Double -> Double -> (Double, String) -> Ribbon -> (Double, String)
+drawArrow ratio len maxVal (start, s) (Ribbon b i) =
( start - i,
s
<> "\\draw "
@@ -57,14 +57,14 @@ drawArrow ratio len (start, s) (Ribbon b i) =
<> ";\n"
)
where
- upper_limit = Limits ((- start) * ratio) (start * ratio)
- lower_limit = Limits ((- start - i) * ratio) ((start - i) * ratio)
+ upper_limit = Limits ((start - maxVal) * ratio) (start * ratio)
+ lower_limit = Limits ((start - i - maxVal) * ratio) ((start - i) * ratio)
mid1 = boolToCoords upper_limit ((fromIntegral $ length b) * len) (last b)
mid2 = boolToCoords lower_limit ((fromIntegral $ length b) * len) (last b)
drawRibbons :: Double -> Double -> [Ribbon] -> String
drawRibbons ratio len rs =
- snd $ foldl (drawArrow ratio len) (total, "") rs
+ snd $ foldl (drawArrow ratio len total) (total, "") rs
where
total = sum $ map (\(Ribbon _ y) -> y) rs