module Graphics.Svg.Path where
import Data.Text (Text)
import qualified Data.Text as T
import Data.Text.Lazy (toStrict)
import Data.Text.Lazy.Builder (toLazyText)
import Data.Text.Lazy.Builder.RealFloat
toText :: RealFloat a => a -> Text
toText = toStrict . toLazyText . formatRealFloat Fixed (Just 4)
mA :: RealFloat a => a -> a -> Text
mA x y = T.concat ["M " ,toText x, ",", toText y, " "]
mR :: RealFloat a => a -> a -> Text
mR dx dy = T.concat ["m ", toText dx, ",", toText dy, " "]
lA :: RealFloat a => a -> a -> Text
lA x y = T.concat ["L ", toText x, ",", toText y, " "]
lR :: RealFloat a => a -> a -> Text
lR dx dy = T.concat ["l ", toText dx, ",", toText dy, " "]
hA :: RealFloat a => a -> Text
hA x = T.concat ["H ", toText x, " "]
hR :: RealFloat a => a -> Text
hR dx = T.concat ["h ", toText dx, " "]
vA :: RealFloat a => a -> Text
vA y = T.concat ["V ", toText y, " "]
vR :: RealFloat a => a -> Text
vR dy = T.concat ["v ", toText dy, " "]
cA :: RealFloat a => a -> a -> a -> a -> a -> a -> Text
cA c1x c1y c2x c2y x y = T.concat
[ "C ", toText c1x, ",", toText c1y, " ", toText c2x, ","
, toText c2y, " ", toText x, " ", toText y]
cR :: RealFloat a => a -> a -> a -> a -> a -> a -> Text
cR dc1x dc1y dc2x dc2y dx dy = T.concat
[ "c ", toText dc1x, ",", toText dc1y, " ", toText dc2x
, ",", toText dc2y, " ", toText dx, " ", toText dy]
sA :: RealFloat a => a -> a -> a -> a -> Text
sA c2x c2y x y = T.concat
["S ", toText c2x, ",", toText c2y, " ", toText x, ",", toText y, " "]
sR :: RealFloat a => a -> a -> a -> a -> Text
sR dc2x dc2y dx dy = T.concat
["s ", toText dc2x, ",", toText dc2y, " ", toText dx, ",", toText dy, " "]
qA :: RealFloat a => a -> a -> a -> a -> Text
qA cx cy x y = T.concat
["Q ", toText cx, ",", toText cy, " ", toText x, ",", toText y, " "]
qR :: RealFloat a => a -> a -> a -> a -> Text
qR dcx dcy dx dy = T.concat
["q ", toText dcx, ",", toText dcy, " ", toText dx, ",", toText dy, " " ]
tA :: RealFloat a => a -> a -> Text
tA x y = T.concat ["T ", " ", toText x, ",", toText y, " "]
tR :: RealFloat a => a -> a -> Text
tR x y = T.concat [ "t ", toText x, ",", toText y, " "]
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, " "]
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, " "]
z :: Text
z = "Z"
translate :: RealFloat a => a -> a -> Text
translate x y = T.concat ["translate(", toText x, " ", toText y, ")"]
scale :: RealFloat a => a -> a -> Text
scale x y = T.concat ["scale(", toText x, " ", toText y, ")"]
rotate :: RealFloat a => a -> Text
rotate angle = T.concat ["rotate(", toText angle, ")"]
rotateAround :: RealFloat a => a -> a -> a -> Text
rotateAround angle rx ry = T.concat
["rotate(", toText angle, ",", toText rx, ",", toText ry, ")"]
skewX :: RealFloat a => a -> Text
skewX angle = T.concat ["skewX(", toText angle, ")"]
skewY :: RealFloat a => a -> Text
skewY angle = T.concat ["skewY(", toText angle, ")"]
matrix :: RealFloat a => a -> a -> a -> a -> a -> a -> Text
matrix a b c d e f = T.concat
[ "matrix(", toText a, ",", toText b, ",", toText c
, ",", toText d, ",", toText e, ",", toText f, ")"]