packages feed

lucid-svg 0.1.0.0 → 0.2.0.0

raw patch · 6 files changed

+195/−141 lines, 6 filesdep +blaze-builderdep ~luciddep ~textdep ~transformersPVP ok

version bump matches the API change (PVP)

Dependencies added: blaze-builder

Dependency ranges changed: lucid, text, transformers

API changes (from Hackage documentation)

- Lucid.Svg.Attributes: clipPath_ :: Text -> Attribute
- Lucid.Svg.Elements: clippath_ :: Term arg result => arg -> result
- Lucid.Svg.Elements: makeElementNoContent :: Monad m => Text -> SvgT m ()
+ Lucid.Svg.Elements: clipPath_ :: Term arg result => arg -> result
+ Lucid.Svg.Path: toText :: Show a => a -> Text
- Lucid.Svg.Path: aA :: Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text
+ Lucid.Svg.Path: aA :: Show a => a -> a -> a -> a -> a -> a -> a -> Text
- Lucid.Svg.Path: aR :: Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text
+ Lucid.Svg.Path: aR :: Show a => a -> a -> a -> a -> a -> a -> a -> Text
- Lucid.Svg.Path: cA :: Text -> Text -> Text -> Text -> Text -> Text -> Text
+ Lucid.Svg.Path: cA :: Show a => a -> a -> a -> a -> a -> a -> Text
- Lucid.Svg.Path: cR :: Text -> Text -> Text -> Text -> Text -> Text -> Text
+ Lucid.Svg.Path: cR :: Show a => a -> a -> a -> a -> a -> a -> Text
- Lucid.Svg.Path: hA :: Text -> Text
+ Lucid.Svg.Path: hA :: Show a => a -> Text
- Lucid.Svg.Path: hR :: Text -> Text
+ Lucid.Svg.Path: hR :: Show a => a -> Text
- Lucid.Svg.Path: lA :: Text -> Text -> Text
+ Lucid.Svg.Path: lA :: Show a => a -> a -> Text
- Lucid.Svg.Path: lR :: Text -> Text -> Text
+ Lucid.Svg.Path: lR :: Show a => a -> a -> Text
- Lucid.Svg.Path: mA :: Text -> Text -> Text
+ Lucid.Svg.Path: mA :: Show a => a -> a -> Text
- Lucid.Svg.Path: mR :: Text -> Text -> Text
+ Lucid.Svg.Path: mR :: Show a => a -> a -> Text
- Lucid.Svg.Path: matrix :: Text -> Text -> Text -> Text -> Text -> Text -> Text
+ Lucid.Svg.Path: matrix :: Show a => a -> a -> a -> a -> a -> a -> Text
- Lucid.Svg.Path: qA :: Text -> Text -> Text -> Text -> Text
+ Lucid.Svg.Path: qA :: Show a => a -> a -> a -> a -> Text
- Lucid.Svg.Path: qR :: Text -> Text -> Text -> Text -> Text
+ Lucid.Svg.Path: qR :: Show a => a -> a -> a -> a -> Text
- Lucid.Svg.Path: rotate :: Text -> Text
+ Lucid.Svg.Path: rotate :: Show a => a -> Text
- Lucid.Svg.Path: rotateAround :: Text -> Text -> Text -> Text
+ Lucid.Svg.Path: rotateAround :: Show a => a -> a -> a -> Text
- Lucid.Svg.Path: sA :: Text -> Text -> Text -> Text -> Text
+ Lucid.Svg.Path: sA :: Show a => a -> a -> a -> a -> Text
- Lucid.Svg.Path: sR :: Text -> Text -> Text -> Text -> Text
+ Lucid.Svg.Path: sR :: Show a => a -> a -> a -> a -> Text
- Lucid.Svg.Path: scale :: Text -> Text -> Text
+ Lucid.Svg.Path: scale :: Show a => a -> a -> Text
- Lucid.Svg.Path: skewX :: Text -> Text
+ Lucid.Svg.Path: skewX :: Show a => a -> Text
- Lucid.Svg.Path: skewY :: Text -> Text
+ Lucid.Svg.Path: skewY :: Show a => a -> Text
- Lucid.Svg.Path: tA :: Text -> Text -> Text
+ Lucid.Svg.Path: tA :: Show a => a -> a -> Text
- Lucid.Svg.Path: tR :: Text -> Text -> Text
+ Lucid.Svg.Path: tR :: Show a => a -> a -> Text
- Lucid.Svg.Path: translate :: Text -> Text -> Text
+ Lucid.Svg.Path: translate :: Show a => a -> a -> Text
- Lucid.Svg.Path: vA :: Text -> Text
+ Lucid.Svg.Path: vA :: Show a => a -> Text
- Lucid.Svg.Path: vR :: Text -> Text
+ Lucid.Svg.Path: vR :: Show a => a -> Text

Files

README.md view
@@ -5,6 +5,8 @@ ## Example  ``` haskell+{-# LANGUAGE OverloadedStrings #-}+ import Lucid.Svg   svg :: Svg () -> Svg ()
lucid-svg.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                lucid-svg-version:             0.1.0.0+version:             0.2.0.0 synopsis:            DSL for SVG using lucid for HTML -- description:          homepage:            http://github.com/jeffreyrosenbluth/lucid-svg.git@@ -22,9 +22,10 @@                        Lucid.Svg.Path,                        Lucid.Svg.Elements,                        Lucid.Svg.Attributes-  build-depends:       base >=4.7 && <4.8,-                       transformers,-                       text,-                       lucid >=2.6 && <2.7+  build-depends:       base          >=4.7 && <4.8,+                       blaze-builder >= 0.3 && < 0.4,+                       transformers  >= 0.4  && < 0.5,+                       text          >= 1.2  && < 1.3,+                       lucid         >=2.6.1 && < 2.7   hs-source-dirs:      src   default-language:    Haskell2010
src/Lucid/Svg.hs view
@@ -1,5 +1,15 @@ {-# OPTIONS -fno-warn-unused-imports #-} +-------------------------------------------------------------------------------+-- |+-- Module      :  Lucid.Svg+-- Copyright   :  (c) 2015 Jeffrey Rosenbluth+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  jeffrey.rosenbluth@gmail.com+--+-- DSL for creating SVG.+--+------------------------------------------------------------------------------- module Lucid.Svg   ( -- * Intro     -- $intro
src/Lucid/Svg/Attributes.hs view
@@ -1,4 +1,15 @@-{-# LANGUAGE OverloadedStrings         #-}+{-# LANGUAGE OverloadedStrings #-}+ +-------------------------------------------------------------------------------+-- |+-- Module      :  Lucid.Svg.Attributes+-- Copyright   :  (c) 2015 Jeffrey Rosenbluth+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  jeffrey.rosenbluth@gmail.com+--+-- SVG Attributes.+--+-------------------------------------------------------------------------------  module Lucid.Svg.Attributes where  @@ -92,10 +103,6 @@ -- | The @clip@ attribute. clip_ :: Text -> Attribute clip_ = makeAttribute "clip"---- | The @clipPath@ attribute.-clipPath_ :: Text -> Attribute-clipPath_ = makeAttribute "clip-path"  -- | The @clipRule@ attribute. clipRule_ :: Text -> Attribute
src/Lucid/Svg/Elements.hs view
@@ -1,19 +1,24 @@ {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE FlexibleContexts          #-}+{-# LANGUAGE FlexibleContexts  #-} +-------------------------------------------------------------------------------+-- |+-- Module      :  Lucid.Svg.Elements+-- Copyright   :  (c) 2015 Jeffrey Rosenbluth+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  jeffrey.rosenbluth@gmail.com+--+-- SVG elements.+--+-------------------------------------------------------------------------------+ module Lucid.Svg.Elements where  -import Data.Text (Text) import Lucid.Base  -- | A type alias for the 'SvgT m a' monad transformer. type SvgT = HtmlT --- | Make an HTML builder for elements with no content, only attributes.---   SVG circle for example.-makeElementNoContent :: Monad m => Text -> SvgT m ()-makeElementNoContent name = makeElement name ""- -- | @DOCTYPE@ element doctype_ :: Monad m => SvgT m () doctype_ = makeElementNoEnd "?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n    \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"" @@ -31,47 +36,47 @@  -- | @altglyph@ element altGlyph_ :: Monad m => [Attribute] -> SvgT m ()-altGlyph_ = with $ makeElementNoContent "altGlyph"+altGlyph_ = with $ makeXmlElementNoEnd "altGlyph"  -- | @altglyphdef@ element altGlyphDef_ :: Monad m => [Attribute] -> SvgT m ()-altGlyphDef_ = with $ makeElementNoContent "altGlyphDef" +altGlyphDef_ = with $ makeXmlElementNoEnd "altGlyphDef"   -- | @altglyphitem@ element altGlyphItem_ :: Monad m => [Attribute] -> SvgT m ()-altGlyphItem_ = with $ makeElementNoContent "altGlyphItem" +altGlyphItem_ = with $ makeXmlElementNoEnd "altGlyphItem"   -- | @animate@ element animate_ :: Monad m => [Attribute] -> SvgT m ()-animate_ = with $ makeElementNoContent "animate" +animate_ = with $ makeXmlElementNoEnd "animate"   -- | @animatecolor@ element animateColor_ :: Monad m => [Attribute] -> SvgT m ()-animateColor_ = with $ makeElementNoContent "animateColor" +animateColor_ = with $ makeXmlElementNoEnd "animateColor"   -- | @animatemotion@ element animateMotion_ :: Monad m => [Attribute] -> SvgT m ()-animateMotion_ = with $ makeElementNoContent "animateMotion" +animateMotion_ = with $ makeXmlElementNoEnd "animateMotion"   -- | @animatetransform@ element animateTransform_ :: Monad m => [Attribute] -> SvgT m ()-animateTransform_ = with $ makeElementNoContent "animateTransform" +animateTransform_ = with $ makeXmlElementNoEnd "animateTransform"   -- | @circle@ element circle_ :: Monad m => [Attribute] -> SvgT m ()-circle_ = with $ makeElementNoContent "circle" +circle_ = with $ makeXmlElementNoEnd "circle"  --- | @clippath@ element-clippath_ :: Term arg result => arg -> result-clippath_ = term "clippath"+-- | @clipPath@ element or attribute+clipPath_ :: Term arg result => arg -> result+clipPath_ = term "clippath"  -- | @colorProfile@ element  colorProfile_ :: Monad m => [Attribute] -> SvgT m ()-colorProfile_ = with $ makeElementNoContent "color-profile" +colorProfile_ = with $ makeXmlElementNoEnd "color-profile"   -- | @cursor@ element cursor_ :: Monad m => [Attribute] -> SvgT m ()-cursor_ = with $ makeElementNoContent "cursor" +cursor_ = with $ makeXmlElementNoEnd "cursor"   -- | @defs@ element defs_ :: Term arg result => arg -> result@@ -79,139 +84,139 @@  -- | @desc@ element desc_ :: Monad m => [Attribute] -> SvgT m ()-desc_ = with $ makeElementNoContent "desc" +desc_ = with $ makeXmlElementNoEnd "desc"   -- | @ellipse@ element ellipse_ :: Monad m => [Attribute] -> SvgT m ()-ellipse_ = with $ makeElementNoContent "ellipse" +ellipse_ = with $ makeXmlElementNoEnd "ellipse"   -- | @feblend@ element feBlend_ :: Monad m => [Attribute] -> SvgT m ()-feBlend_ = with $ makeElementNoContent "feBlend" +feBlend_ = with $ makeXmlElementNoEnd "feBlend"   -- | @fecolormatrix@ element feColorMatrix_ :: Monad m => [Attribute] -> SvgT m ()-feColorMatrix_ = with $ makeElementNoContent "feColorMatrix" +feColorMatrix_ = with $ makeXmlElementNoEnd "feColorMatrix"   -- | @fecomponenttransfer@ element feComponentTransfer_ :: Monad m => [Attribute] -> SvgT m ()-feComponentTransfer_ = with $ makeElementNoContent "feComponentTransfer" +feComponentTransfer_ = with $ makeXmlElementNoEnd "feComponentTransfer"   -- | @fecomposite@ element feComposite_ :: Monad m => [Attribute] -> SvgT m ()-feComposite_ = with $ makeElementNoContent "feComposite" +feComposite_ = with $ makeXmlElementNoEnd "feComposite"   -- | @feconvolvematrix@ element feConvolveMatrix_ :: Monad m => [Attribute] -> SvgT m ()-feConvolveMatrix_ = with $ makeElementNoContent "feConvolveMatrix" +feConvolveMatrix_ = with $ makeXmlElementNoEnd "feConvolveMatrix"   -- | @fediffuselighting@ element feDiffuseLighting_ :: Monad m => [Attribute] -> SvgT m ()-feDiffuseLighting_ = with $ makeElementNoContent "feDiffuseLighting" +feDiffuseLighting_ = with $ makeXmlElementNoEnd "feDiffuseLighting"   -- | @fedisplacementmap@ element feDisplacementMap_ :: Monad m => [Attribute] -> SvgT m ()-feDisplacementMap_ = with $ makeElementNoContent "feDisplacementMap" +feDisplacementMap_ = with $ makeXmlElementNoEnd "feDisplacementMap"   -- | @fedistantlight@ element feDistantLight_ :: Monad m => [Attribute] -> SvgT m ()-feDistantLight_ = with $ makeElementNoContent "feDistantLight" +feDistantLight_ = with $ makeXmlElementNoEnd "feDistantLight"   -- | @feflood@ element feFlood_ :: Monad m => [Attribute] -> SvgT m ()-feFlood_ = with $ makeElementNoContent "feFlood" +feFlood_ = with $ makeXmlElementNoEnd "feFlood"   -- | @fefunca@ element feFuncA_ :: Monad m => [Attribute] -> SvgT m ()-feFuncA_ = with $ makeElementNoContent "feFuncA" +feFuncA_ = with $ makeXmlElementNoEnd "feFuncA"   -- | @fefuncb@ element feFuncB_ :: Monad m => [Attribute] -> SvgT m ()-feFuncB_ = with $ makeElementNoContent "feFuncB" +feFuncB_ = with $ makeXmlElementNoEnd "feFuncB"   -- | @fefuncg@ element feFuncG_ :: Monad m => [Attribute] -> SvgT m ()-feFuncG_ = with $ makeElementNoContent "feFuncG" +feFuncG_ = with $ makeXmlElementNoEnd "feFuncG"   -- | @fefuncr@ element feFuncR_ :: Monad m => [Attribute] -> SvgT m ()-feFuncR_ = with $ makeElementNoContent "feFuncR" +feFuncR_ = with $ makeXmlElementNoEnd "feFuncR"   -- | @fegaussianblur@ element feGaussianBlur_ :: Monad m => [Attribute] -> SvgT m ()-feGaussianBlur_ = with $ makeElementNoContent "feGaussianBlur" +feGaussianBlur_ = with $ makeXmlElementNoEnd "feGaussianBlur"   -- | @feimage@ element feImage_ :: Monad m => [Attribute] -> SvgT m ()-feImage_ = with $ makeElementNoContent "feImage" +feImage_ = with $ makeXmlElementNoEnd "feImage"   -- | @femerge@ element feMerge_ :: Monad m => [Attribute] -> SvgT m ()-feMerge_ = with $ makeElementNoContent "feMerge" +feMerge_ = with $ makeXmlElementNoEnd "feMerge"   -- | @femergenode@ element feMergeNode_ :: Monad m => [Attribute] -> SvgT m ()-feMergeNode_ = with $ makeElementNoContent "feMergeNode" +feMergeNode_ = with $ makeXmlElementNoEnd "feMergeNode"   -- | @femorphology@ element feMorphology_ :: Monad m => [Attribute] -> SvgT m ()-feMorphology_ = with $ makeElementNoContent "feMorphology" +feMorphology_ = with $ makeXmlElementNoEnd "feMorphology"   -- | @feoffset@ element feOffset_ :: Monad m => [Attribute] -> SvgT m ()-feOffset_ = with $ makeElementNoContent "feOffset" +feOffset_ = with $ makeXmlElementNoEnd "feOffset"   -- | @fepointlight@ element fePointLight_ :: Monad m => [Attribute] -> SvgT m ()-fePointLight_ = with $ makeElementNoContent "fePointLight" +fePointLight_ = with $ makeXmlElementNoEnd "fePointLight"   -- | @fespecularlighting@ element feSpecularLighting_ :: Monad m => [Attribute] -> SvgT m ()-feSpecularLighting_ = with $ makeElementNoContent "feSpecularLighting" +feSpecularLighting_ = with $ makeXmlElementNoEnd "feSpecularLighting"   -- | @fespotlight@ element feSpotLight_ :: Monad m => [Attribute] -> SvgT m ()-feSpotLight_ = with $ makeElementNoContent "feSpotLight" +feSpotLight_ = with $ makeXmlElementNoEnd "feSpotLight"   -- | @fetile@ element feTile_ :: Monad m => [Attribute] -> SvgT m ()-feTile_ = with $ makeElementNoContent "feTile" +feTile_ = with $ makeXmlElementNoEnd "feTile"   -- | @feturbulence@ element feTurbulence_ :: Monad m => [Attribute] -> SvgT m ()-feTurbulence_ = with $ makeElementNoContent "feTurbulence" +feTurbulence_ = with $ makeXmlElementNoEnd "feTurbulence"   -- | @filter_@ element filter_ :: Monad m => [Attribute] -> SvgT m ()-filter_ = with $ makeElementNoContent "filter" +filter_ = with $ makeXmlElementNoEnd "filter"   -- | @font@ element font_ :: Monad m => [Attribute] -> SvgT m ()-font_ = with $ makeElementNoContent "font" +font_ = with $ makeXmlElementNoEnd "font"   -- | @fontFace@ element fontFace_ :: Monad m => [Attribute] -> SvgT m ()-fontFace_ = with $ makeElementNoContent "font-face" +fontFace_ = with $ makeXmlElementNoEnd "font-face"   -- | @fontFaceFormat@ element fontFaceFormat_ :: Monad m => [Attribute] -> SvgT m ()-fontFaceFormat_ = with $ makeElementNoContent "font-face-format" +fontFaceFormat_ = with $ makeXmlElementNoEnd "font-face-format"   -- | @fontFaceName@ element fontFaceName_ :: Monad m => [Attribute] -> SvgT m ()-fontFaceName_ = with $ makeElementNoContent "font-face-name" +fontFaceName_ = with $ makeXmlElementNoEnd "font-face-name"   -- | @fontFaceSrc@ element fontFaceSrc_ :: Monad m => [Attribute] -> SvgT m ()-fontFaceSrc_ = with $ makeElementNoContent "font-face-src" +fontFaceSrc_ = with $ makeXmlElementNoEnd "font-face-src"   -- | @fontFaceUri@ element fontFaceUri_ :: Monad m => [Attribute] -> SvgT m ()-fontFaceUri_ = with $ makeElementNoContent "font-face-uri" +fontFaceUri_ = with $ makeXmlElementNoEnd "font-face-uri"   -- | @foreignobject@ element foreignObject_ :: Monad m => [Attribute] -> SvgT m ()-foreignObject_ = with $ makeElementNoContent "foreignObject" +foreignObject_ = with $ makeXmlElementNoEnd "foreignObject"   -- | @g@ element g_ :: Term arg result => arg -> result@@ -223,19 +228,19 @@  -- | @glyphref@ element glyphRef_ :: Monad m => [Attribute] -> SvgT m ()-glyphRef_ = with $ makeElementNoContent "glyphRef" +glyphRef_ = with $ makeXmlElementNoEnd "glyphRef"   -- | @hkern@ element hkern_ :: Monad m => [Attribute] -> SvgT m ()-hkern_ = with $ makeElementNoContent "hkern" +hkern_ = with $ makeXmlElementNoEnd "hkern"   -- | @image@ element image_ :: Monad m => [Attribute] -> SvgT m ()-image_ = with $ makeElementNoContent "image" +image_ = with $ makeXmlElementNoEnd "image"   -- | @line@ element line_ :: Monad m => [Attribute] -> SvgT m ()-line_ = with $ makeElementNoContent "line" +line_ = with $ makeXmlElementNoEnd "line"   -- | @lineargradient@ element linearGradient_ :: Term arg result => arg -> result@@ -251,7 +256,7 @@  -- | @metadata@ element metadata_ :: Monad m => [Attribute] -> SvgT m ()-metadata_ = with $ makeElementNoContent "metadata" +metadata_ = with $ makeXmlElementNoEnd "metadata"   -- | @missingGlyph@ element missingGlyph_ :: Term arg result => arg -> result@@ -259,11 +264,11 @@  -- | @mpath@ element mpath_ :: Monad m => [Attribute] -> SvgT m ()-mpath_ = with $ makeElementNoContent "mpath" +mpath_ = with $ makeXmlElementNoEnd "mpath"   -- | @path@ element path_ :: Monad m => [Attribute] -> SvgT m ()-path_ = with $ makeElementNoContent "path" +path_ = with $ makeXmlElementNoEnd "path"   -- | @pattern@ element pattern_ :: Term arg result => arg -> result@@ -271,11 +276,11 @@  -- | @polygon@ element polygon_ :: Monad m => [Attribute] -> SvgT m ()-polygon_ = with $ makeElementNoContent "polygon" +polygon_ = with $ makeXmlElementNoEnd "polygon"   -- | @polyline@ element polyline_ :: Monad m => [Attribute] -> SvgT m ()-polyline_ = with $ makeElementNoContent "polyline" +polyline_ = with $ makeXmlElementNoEnd "polyline"   -- | @radialgradient@ element radialGradient_ :: Term arg result => arg -> result@@ -283,23 +288,23 @@  -- | @rect@ element rect_ :: Monad m => [Attribute] -> SvgT m ()-rect_ = with $ makeElementNoContent "rect"+rect_ = with $ makeXmlElementNoEnd "rect"  -- | @script@ element script_ :: Monad m => [Attribute] -> SvgT m ()-script_ = with $ makeElementNoContent "script" +script_ = with $ makeXmlElementNoEnd "script"   -- | @set@ element set_ :: Monad m => [Attribute] -> SvgT m ()-set_ = with $ makeElementNoContent "set" +set_ = with $ makeXmlElementNoEnd "set"   -- | @stop@ element stop_ :: Monad m => [Attribute] -> SvgT m ()-stop_ = with $ makeElementNoContent "stop" +stop_ = with $ makeXmlElementNoEnd "stop"   -- | @style@ element style_ :: Monad m => [Attribute] -> SvgT m ()-style_ = with $ makeElementNoContent "style" +style_ = with $ makeXmlElementNoEnd "style"   -- | @svg@ element svg_ :: Term arg result => arg -> result@@ -319,28 +324,28 @@  -- | @textpath@ element textPath_ :: Monad m => [Attribute] -> SvgT m ()-textPath_ = with $ makeElementNoContent "textPath" +textPath_ = with $ makeXmlElementNoEnd "textPath"   -- | @title@ element title_ :: Monad m => [Attribute] -> SvgT m ()-title_ = with $ makeElementNoContent "title" +title_ = with $ makeXmlElementNoEnd "title"   -- | @tref@ element tref_ :: Monad m => [Attribute] -> SvgT m ()-tref_ = with $ makeElementNoContent "tref" +tref_ = with $ makeXmlElementNoEnd "tref"   -- | @tspan@ element tspan_ :: Monad m => [Attribute] -> SvgT m ()-tspan_ = with $ makeElementNoContent "tspan" +tspan_ = with $ makeXmlElementNoEnd "tspan"   -- | @use@ element use_ :: Monad m => [Attribute] -> SvgT m ()-use_ = with $ makeElementNoContent "use" +use_ = with $ makeXmlElementNoEnd "use"   -- | @view@ element view_ :: Monad m => [Attribute] -> SvgT m ()-view_ = with $ makeElementNoContent "view" +view_ = with $ makeXmlElementNoEnd "view"   -- | @vkern@ element vkern_ :: Monad m => [Attribute] -> SvgT m ()-vkern_ = with $ makeElementNoContent "vkern" +vkern_ = with $ makeXmlElementNoEnd "vkern" 
src/Lucid/Svg/Path.hs view
@@ -1,84 +1,110 @@-{-# LANGUAGE FlexibleContexts          #-}-{-# LANGUAGE OverloadedStrings         #-}+{-# LANGUAGE FlexibleContexts  #-}+{-# LANGUAGE OverloadedStrings #-} +-------------------------------------------------------------------------------+-- |+-- Module      :  Lucid.Svg.Path+-- Copyright   :  (c) 2015 Jeffrey Rosenbluth+-- License     :  BSD-style (see LICENSE)+-- Maintainer  :  jeffrey.rosenbluth@gmail.com+--+-- Utility functions to help create SVG path attributes,+-- and transforms.+--+-------------------------------------------------------------------------------+ module Lucid.Svg.Path where -import           Data.Text             (Text)+import           Data.Text             (Text, pack) import qualified Data.Text             as T ---   moveto (absolute)-mA :: Text -> Text -> Text-mA x y = T.concat ["M " ,x, ",", y, " "]+-- | Convert a showable object to Text.+toText :: Show a => a -> Text+toText = pack . show +-- | moveto (absolute)+mA :: Show a =>  a -> a -> Text+mA x y = T.concat ["M " ,toText x, ",", toText y, " "]+ -- | moveto (relative)-mR :: Text -> Text -> Text-mR dx dy = T.concat ["m ", dx, ",", dy, " "]+mR :: Show a =>  a -> a -> Text+mR dx dy = T.concat ["m ", toText dx, ",", toText dy, " "]  -- | lineto (absolute)-lA :: Text -> Text -> Text-lA x y = T.concat ["L ", x, ",", y, " "]+lA :: Show a =>  a -> a -> Text+lA x y = T.concat ["L ", toText x, ",", toText y, " "]  -- | lineto (relative)-lR :: Text -> Text -> Text-lR dx dy = T.concat ["l ", dx, ",", dy, " "]+lR :: Show a =>  a -> a -> Text+lR dx dy = T.concat ["l ", toText dx, ",", toText dy, " "]  -- | horizontal lineto (absolute)-hA :: Text -> Text-hA x = T.concat ["H ", x, " "]+hA :: Show a =>  a -> Text+hA x = T.concat ["H ", toText x, " "]  -- | horizontal lineto (relative)-hR :: Text -> Text-hR dx = T.concat ["h ", dx, " "]+hR :: Show a =>  a -> Text+hR dx = T.concat ["h ", toText dx, " "]  -- | vertical lineto (absolute)-vA :: Text -> Text-vA y = T.concat ["V ", y, " "]+vA :: Show a =>  a -> Text+vA y = T.concat ["V ", toText y, " "]  -- | vertical lineto (relative)-vR :: Text -> Text-vR dy = T.concat ["v ", dy, " "]+vR :: Show a =>  a -> Text+vR dy = T.concat ["v ", toText dy, " "]  -- | Cubic Bezier curve (absolute)-cA :: Text -> Text -> Text -> Text -> Text -> Text -> Text-cA c1x c1y c2x c2y x y = T.concat ["C ", c1x, ",", c1y, " ", c2x, ",", c2y, " ", x, " ", y]+cA :: Show 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]  -- | Cubic Bezier curve (relative)-cR :: Text -> Text -> Text -> Text -> Text -> Text -> Text-cR dc1x dc1y dc2x dc2y dx dy = T.concat ["c ", dc1x, ",", dc1y, " ", dc2x, ",", dc2y, " ", dx, " ", dy]+cR :: Show 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]  -- | Smooth Cubic Bezier curve (absolute)-sA :: Text -> Text -> Text -> Text -> Text-sA c2x c2y x y = T.concat ["S ", c2x, ",", c2y, " ", x, ",", y, " "]+sA :: Show a =>  a -> a -> a -> a -> Text+sA c2x c2y x y = T.concat+  ["S ", toText c2x, ",", toText c2y, " ", toText x, ",", toText y, " "]  -- | Smooth Cubic Bezier curve (relative)-sR :: Text -> Text -> Text -> Text -> Text-sR dc2x dc2y dx dy = T.concat ["s ", dc2x, ",", dc2y, " ", dx, ",", dy, " "]+sR :: Show a =>  a -> a -> a -> a -> Text+sR dc2x dc2y dx dy = T.concat+  ["s ", toText dc2x, ",", toText dc2y, " ", toText dx, ",", toText dy, " "]  -- | Quadratic Bezier curve (absolute)-qA :: Text -> Text -> Text -> Text -> Text-qA cx cy x y = T.concat ["Q ", cx, ",", cy, " ", x, ",", y, " "]+qA :: Show a =>  a -> a -> a -> a -> Text+qA cx cy x y = T.concat+  ["Q ", toText cx, ",", toText cy, " ", toText x, ",", toText y, " "]  -- | Quadratic Bezier curve (relative)-qR :: Text -> Text -> Text -> Text -> Text-qR dcx dcy dx dy = T.concat ["q ", dcx, ",", dcy, " ", dx, ",", dy, " " ]+qR :: Show a =>  a -> a -> a -> a -> Text+qR dcx dcy dx dy = T.concat+  ["q ", toText dcx, ",", toText dcy, " ", toText dx, ",", toText dy, " " ]  -- | Smooth Quadratic Bezier curve (absolute)-tA  :: Text -> Text -> Text-tA x y = T.concat ["T ", " ", x, ",", y, " "]+tA  :: Show a =>  a -> a -> Text+tA x y = T.concat ["T ", " ", toText x, ",", toText y, " "]  -- | Smooth Quadratic Bezier curve (relative)-tR :: Text -> Text -> Text-tR x y = T.concat [ "t ", x, ",", y, " "]+tR :: Show a =>  a -> a -> Text+tR x y = T.concat [ "t ", toText x, ",", toText y, " "]  -- | Arc (absolute)-aA :: Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text-aA rx ry xrot largeFlag sweepFlag x y =-  T.concat ["A ", rx, ",", ry, " ", xrot, " ", largeFlag, " ", sweepFlag, " ", x, " ", y, " "]+aA :: Show 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, " "]  -- | Arc (relative)-aR :: Text -> Text -> Text -> Text -> Text -> Text -> Text -> Text-aR rx ry xrot largeFlag sweepFlag x y =-  T.concat ["a ", rx, ",", ry, " ", xrot, " ", largeFlag, " ", sweepFlag, " ", x, " ", y, " "]+aR :: Show 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, " "]  -- | closepath z :: Text@@ -86,29 +112,32 @@  -- | SVG Transform components -- | Specifies a translation by @x@ and @y@-translate :: Text -> Text -> Text-translate x y = T.concat ["translate(", x, " ", y, ")"]+translate :: Show a =>  a -> a -> Text+translate x y = T.concat ["translate(", toText x, " ", toText y, ")"]  -- | Specifies a scale operation by @x@ and @y@-scale :: Text -> Text -> Text-scale x y = T.concat ["scale(", x, " ", y, ")"]+scale :: Show a =>  a -> a -> Text+scale x y = T.concat ["scale(", toText x, " ", toText y, ")"]  -- | Specifies a rotation by @rotate-angle@ degrees-rotate :: Text -> Text-rotate angle = T.concat ["rotate(", angle, ")"]+rotate :: Show a =>  a -> Text+rotate angle = T.concat ["rotate(", toText angle, ")"]  -- | Specifies a rotation by @rotate-angle@ degrees about the given time @rx,ry@-rotateAround :: Text -> Text -> Text -> Text-rotateAround angle rx ry = T.concat ["rotate(", angle, ",", rx, ",", ry, ")"]+rotateAround :: Show a =>  a -> a -> a -> Text+rotateAround angle rx ry = T.concat+  ["rotate(", toText angle, ",", toText rx, ",", toText ry, ")"]  -- | Skew tansformation along x-axis-skewX :: Text -> Text-skewX angle = T.concat ["skewX(", angle, ")"]+skewX :: Show a =>  a -> Text+skewX angle = T.concat ["skewX(", toText angle, ")"]  -- | Skew tansformation along y-axis-skewY :: Text -> Text-skewY angle = T.concat ["skewY(", angle, ")"]+skewY :: Show a =>  a -> Text+skewY angle = T.concat ["skewY(", toText angle, ")"]  -- | Specifies a transform in the form of a transformation matrix-matrix :: Text -> Text -> Text -> Text -> Text -> Text -> Text-matrix a b c_ d e f =  T.concat ["matrix(",  a, ",",  b, ",",  c_, ",",  d, ",", e, ",",  f, ")"]+matrix :: Show 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, ")"]