From 6bda613b538b08e9947913382f3b94235ca92149 Mon Sep 17 00:00:00 2001 From: Rhiannon Morris Date: Tue, 3 Nov 2020 18:21:50 +0100 Subject: [PATCH] fix arc/sweep flags --- src/Graphics/Svg/Path.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Graphics/Svg/Path.hs b/src/Graphics/Svg/Path.hs index 4af095b..ee7a7b5 100644 --- a/src/Graphics/Svg/Path.hs +++ b/src/Graphics/Svg/Path.hs @@ -25,6 +25,10 @@ import Data.Text.Lazy.Builder.RealFloat toText :: RealFloat a => a -> Text toText = toStrict . toLazyText . formatRealFloat Fixed (Just 4) +-- | Convert an arc/sweep flag to text +toFlag :: (Num a, Eq a) => a -> Text +toFlag x = if x == 0 then "0" else "1" + -- | moveto (absolute) mA :: RealFloat a => a -> a -> Text mA x y = T.concat ["M " ,toText x, ",", toText y, " "] @@ -100,14 +104,14 @@ tR x y = T.concat [ "t ", toText x, ",", toText y, " "] -- | Arc (absolute) aA :: RealFloat a => a -> a -> a -> a -> a -> a -> a -> Text aA rx ry xrot largeFlag sweepFlag x y = T.concat - [ "A ", toText rx, ",", toText ry, " ", toText xrot, " ", toText largeFlag - , " ", toText sweepFlag, " ", toText x, " ", toText y, " "] + [ "A ", toText rx, ",", toText ry, " ", toText xrot, " ", toFlag largeFlag + , " ", toFlag sweepFlag, " ", toText x, " ", toText y, " "] -- | Arc (relative) aR :: RealFloat a => a -> a -> a -> a -> a -> a -> a -> Text aR rx ry xrot largeFlag sweepFlag x y = T.concat - [ "a ", toText rx, ",", toText ry, " ", toText xrot, " ", toText largeFlag - , " ", toText sweepFlag, " ", toText x, " ", toText y, " "] + [ "a ", toText rx, ",", toText ry, " ", toText xrot, " ", toFlag largeFlag + , " ", toFlag sweepFlag, " ", toText x, " ", toText y, " "] -- | closepath z :: Text