fix arc/sweep flags

This commit is contained in:
Rhiannon Morris 2020-11-03 18:21:50 +01:00
parent 4dc0c0394b
commit 6bda613b53
1 changed files with 8 additions and 4 deletions

View File

@ -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