packages feed

reanimate-svg 0.9.3.1 → 0.9.4.0

raw patch · 5 files changed

+36/−31 lines, 5 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Graphics.SvgTree: resolveUses :: Document -> Document
- Graphics.SvgTree.Types: [_definitions] :: Document -> Map String Tree
- Graphics.SvgTree.Types: definitions :: HasDocument c_axMi => Lens' c_axMi (Map String Tree)
+ Graphics.SvgTree.Types: SvgTree :: !Document -> Tree
+ Graphics.SvgTree.Types: instance GHC.Classes.Eq Graphics.SvgTree.Types.Document
- Graphics.SvgTree.Types: Document :: Maybe (Double, Double, Double, Double) -> Maybe Number -> Maybe Number -> [Tree] -> Map String Tree -> String -> FilePath -> PreserveAspectRatio -> Document
+ Graphics.SvgTree.Types: Document :: Maybe (Double, Double, Double, Double) -> Maybe Number -> Maybe Number -> [Tree] -> String -> FilePath -> PreserveAspectRatio -> Document
- Graphics.SvgTree.Types: class HasColorMatrix c_ayKz
+ Graphics.SvgTree.Types: class HasColorMatrix c_ayLq
- Graphics.SvgTree.Types: class HasComposite c_ayBi
+ Graphics.SvgTree.Types: class HasComposite c_ayC9
- Graphics.SvgTree.Types: class HasDocument c_axMi
+ Graphics.SvgTree.Types: class HasDocument c_axOb
- Graphics.SvgTree.Types: class HasGaussianBlur c_ayPM
+ Graphics.SvgTree.Types: class HasGaussianBlur c_ayQD
- Graphics.SvgTree.Types: class HasTextPath c_ayps
+ Graphics.SvgTree.Types: class HasTextPath c_ayqj
- Graphics.SvgTree.Types: colorMatrix :: HasColorMatrix c_ayKz => Lens' c_ayKz ColorMatrix
+ Graphics.SvgTree.Types: colorMatrix :: HasColorMatrix c_ayLq => Lens' c_ayLq ColorMatrix
- Graphics.SvgTree.Types: colorMatrixDrawAttributes :: HasColorMatrix c_ayKz => Lens' c_ayKz DrawAttributes
+ Graphics.SvgTree.Types: colorMatrixDrawAttributes :: HasColorMatrix c_ayLq => Lens' c_ayLq DrawAttributes
- Graphics.SvgTree.Types: colorMatrixFilterAttr :: HasColorMatrix c_ayKz => Lens' c_ayKz FilterAttributes
+ Graphics.SvgTree.Types: colorMatrixFilterAttr :: HasColorMatrix c_ayLq => Lens' c_ayLq FilterAttributes
- Graphics.SvgTree.Types: colorMatrixIn :: HasColorMatrix c_ayKz => Lens' c_ayKz (Last FilterSource)
+ Graphics.SvgTree.Types: colorMatrixIn :: HasColorMatrix c_ayLq => Lens' c_ayLq (Last FilterSource)
- Graphics.SvgTree.Types: colorMatrixType :: HasColorMatrix c_ayKz => Lens' c_ayKz ColorMatrixType
+ Graphics.SvgTree.Types: colorMatrixType :: HasColorMatrix c_ayLq => Lens' c_ayLq ColorMatrixType
- Graphics.SvgTree.Types: colorMatrixValues :: HasColorMatrix c_ayKz => Lens' c_ayKz String
+ Graphics.SvgTree.Types: colorMatrixValues :: HasColorMatrix c_ayLq => Lens' c_ayLq String
- Graphics.SvgTree.Types: composite :: HasComposite c_ayBi => Lens' c_ayBi Composite
+ Graphics.SvgTree.Types: composite :: HasComposite c_ayC9 => Lens' c_ayC9 Composite
- Graphics.SvgTree.Types: compositeDrawAttributes :: HasComposite c_ayBi => Lens' c_ayBi DrawAttributes
+ Graphics.SvgTree.Types: compositeDrawAttributes :: HasComposite c_ayC9 => Lens' c_ayC9 DrawAttributes
- Graphics.SvgTree.Types: compositeFilterAttr :: HasComposite c_ayBi => Lens' c_ayBi FilterAttributes
+ Graphics.SvgTree.Types: compositeFilterAttr :: HasComposite c_ayC9 => Lens' c_ayC9 FilterAttributes
- Graphics.SvgTree.Types: compositeIn :: HasComposite c_ayBi => Lens' c_ayBi (Last FilterSource)
+ Graphics.SvgTree.Types: compositeIn :: HasComposite c_ayC9 => Lens' c_ayC9 (Last FilterSource)
- Graphics.SvgTree.Types: compositeIn2 :: HasComposite c_ayBi => Lens' c_ayBi (Last FilterSource)
+ Graphics.SvgTree.Types: compositeIn2 :: HasComposite c_ayC9 => Lens' c_ayC9 (Last FilterSource)
- Graphics.SvgTree.Types: compositeK1 :: HasComposite c_ayBi => Lens' c_ayBi Number
+ Graphics.SvgTree.Types: compositeK1 :: HasComposite c_ayC9 => Lens' c_ayC9 Number
- Graphics.SvgTree.Types: compositeK2 :: HasComposite c_ayBi => Lens' c_ayBi Number
+ Graphics.SvgTree.Types: compositeK2 :: HasComposite c_ayC9 => Lens' c_ayC9 Number
- Graphics.SvgTree.Types: compositeK3 :: HasComposite c_ayBi => Lens' c_ayBi Number
+ Graphics.SvgTree.Types: compositeK3 :: HasComposite c_ayC9 => Lens' c_ayC9 Number
- Graphics.SvgTree.Types: compositeK4 :: HasComposite c_ayBi => Lens' c_ayBi Number
+ Graphics.SvgTree.Types: compositeK4 :: HasComposite c_ayC9 => Lens' c_ayC9 Number
- Graphics.SvgTree.Types: compositeOperator :: HasComposite c_ayBi => Lens' c_ayBi CompositeOperator
+ Graphics.SvgTree.Types: compositeOperator :: HasComposite c_ayC9 => Lens' c_ayC9 CompositeOperator
- Graphics.SvgTree.Types: description :: HasDocument c_axMi => Lens' c_axMi String
+ Graphics.SvgTree.Types: description :: HasDocument c_axOb => Lens' c_axOb String
- Graphics.SvgTree.Types: document :: HasDocument c_axMi => Lens' c_axMi Document
+ Graphics.SvgTree.Types: document :: HasDocument c_axOb => Lens' c_axOb Document
- Graphics.SvgTree.Types: documentAspectRatio :: HasDocument c_axMi => Lens' c_axMi PreserveAspectRatio
+ Graphics.SvgTree.Types: documentAspectRatio :: HasDocument c_axOb => Lens' c_axOb PreserveAspectRatio
- Graphics.SvgTree.Types: documentLocation :: HasDocument c_axMi => Lens' c_axMi FilePath
+ Graphics.SvgTree.Types: documentLocation :: HasDocument c_axOb => Lens' c_axOb FilePath
- Graphics.SvgTree.Types: elements :: HasDocument c_axMi => Lens' c_axMi [Tree]
+ Graphics.SvgTree.Types: elements :: HasDocument c_axOb => Lens' c_axOb [Tree]
- Graphics.SvgTree.Types: gaussianBlur :: HasGaussianBlur c_ayPM => Lens' c_ayPM GaussianBlur
+ Graphics.SvgTree.Types: gaussianBlur :: HasGaussianBlur c_ayQD => Lens' c_ayQD GaussianBlur
- Graphics.SvgTree.Types: gaussianBlurDrawAttributes :: HasGaussianBlur c_ayPM => Lens' c_ayPM DrawAttributes
+ Graphics.SvgTree.Types: gaussianBlurDrawAttributes :: HasGaussianBlur c_ayQD => Lens' c_ayQD DrawAttributes
- Graphics.SvgTree.Types: gaussianBlurEdgeMode :: HasGaussianBlur c_ayPM => Lens' c_ayPM EdgeMode
+ Graphics.SvgTree.Types: gaussianBlurEdgeMode :: HasGaussianBlur c_ayQD => Lens' c_ayQD EdgeMode
- Graphics.SvgTree.Types: gaussianBlurFilterAttr :: HasGaussianBlur c_ayPM => Lens' c_ayPM FilterAttributes
+ Graphics.SvgTree.Types: gaussianBlurFilterAttr :: HasGaussianBlur c_ayQD => Lens' c_ayQD FilterAttributes
- Graphics.SvgTree.Types: gaussianBlurIn :: HasGaussianBlur c_ayPM => Lens' c_ayPM (Last FilterSource)
+ Graphics.SvgTree.Types: gaussianBlurIn :: HasGaussianBlur c_ayQD => Lens' c_ayQD (Last FilterSource)
- Graphics.SvgTree.Types: gaussianBlurStdDeviationX :: HasGaussianBlur c_ayPM => Lens' c_ayPM Number
+ Graphics.SvgTree.Types: gaussianBlurStdDeviationX :: HasGaussianBlur c_ayQD => Lens' c_ayQD Number
- Graphics.SvgTree.Types: gaussianBlurStdDeviationY :: HasGaussianBlur c_ayPM => Lens' c_ayPM (Last Number)
+ Graphics.SvgTree.Types: gaussianBlurStdDeviationY :: HasGaussianBlur c_ayQD => Lens' c_ayQD (Last Number)
- Graphics.SvgTree.Types: height :: HasDocument c_axMi => Lens' c_axMi (Maybe Number)
+ Graphics.SvgTree.Types: height :: HasDocument c_axOb => Lens' c_axOb (Maybe Number)
- Graphics.SvgTree.Types: textPath :: HasTextPath c_ayps => Lens' c_ayps TextPath
+ Graphics.SvgTree.Types: textPath :: HasTextPath c_ayqj => Lens' c_ayqj TextPath
- Graphics.SvgTree.Types: textPathMethod :: HasTextPath c_ayps => Lens' c_ayps TextPathMethod
+ Graphics.SvgTree.Types: textPathMethod :: HasTextPath c_ayqj => Lens' c_ayqj TextPathMethod
- Graphics.SvgTree.Types: textPathName :: HasTextPath c_ayps => Lens' c_ayps String
+ Graphics.SvgTree.Types: textPathName :: HasTextPath c_ayqj => Lens' c_ayqj String
- Graphics.SvgTree.Types: textPathSpacing :: HasTextPath c_ayps => Lens' c_ayps TextPathSpacing
+ Graphics.SvgTree.Types: textPathSpacing :: HasTextPath c_ayqj => Lens' c_ayqj TextPathSpacing
- Graphics.SvgTree.Types: textPathStartOffset :: HasTextPath c_ayps => Lens' c_ayps Number
+ Graphics.SvgTree.Types: textPathStartOffset :: HasTextPath c_ayqj => Lens' c_ayqj Number
- Graphics.SvgTree.Types: viewBox :: HasDocument c_axMi => Lens' c_axMi (Maybe (Double, Double, Double, Double))
+ Graphics.SvgTree.Types: viewBox :: HasDocument c_axOb => Lens' c_axOb (Maybe (Double, Double, Double, Double))
- Graphics.SvgTree.Types: width :: HasDocument c_axMi => Lens' c_axMi (Maybe Number)
+ Graphics.SvgTree.Types: width :: HasDocument c_axOb => Lens' c_axOb (Maybe Number)

Files

reanimate-svg.cabal view
@@ -1,5 +1,5 @@ name:                reanimate-svg-version:             0.9.3.1+version:             0.9.4.0 synopsis:            SVG file loader and serializer description:   reanimate-svg provides types representing a SVG document,
src/Graphics/SvgTree.hs view
@@ -14,7 +14,7 @@   , cssApply   , cssRulesOfText   -- , applyCSSRules-  , resolveUses+  -- , resolveUses      -- * Type definitions   , module Graphics.SvgTree.Types@@ -27,7 +27,7 @@ import           Control.Lens import qualified Data.ByteString            as B import           Data.List                  (foldl')-import qualified Data.Map                   as M+-- import qualified Data.Map                   as M import qualified Data.Text                  as T import           Text.XML.Light.Input       (parseXMLDoc) import           Text.XML.Light.Output      (ppcTopElement, prettyConfigPP)@@ -83,18 +83,18 @@      attr = view drawAttributes t      attr' = foldl' cssDeclApplyer attr matchingDeclarations --- | For every 'use' tag, try to resolve the geometry associated+-- For every 'use' tag, try to resolve the geometry associated -- with it and place it in the scene Tree. It is important to -- resolve the 'use' tag before applying the CSS rules, as some -- rules may apply some elements matching the children of "use".-resolveUses :: Document -> Document-resolveUses doc =-  doc { _elements = mapTree fetchUses <$> _elements doc }-  where-    fetchUses (UseTree useInfo _) = UseTree useInfo $ search useInfo-    fetchUses a                   = a--    search nfo = M.lookup (_useName nfo) $ _definitions doc+-- resolveUses :: Document -> Document+-- resolveUses doc =+--   doc { _elements = mapTree fetchUses <$> _elements doc }+--   where+--     fetchUses (UseTree useInfo _) = UseTree useInfo $ search useInfo+--     fetchUses a                   = a+--+--     search nfo = M.lookup (_useName nfo) $ _definitions doc  -- -- | Rewrite the document by applying the CSS rules embedded -- -- inside it.
src/Graphics/SvgTree/Printer.hs view
@@ -3,16 +3,15 @@   , ppDocument   ) where -import           Control.Lens-import           Data.Char+import           Control.Lens               ((^.)) import           Data.List-import           Graphics.SvgTree.Types     (Document (..), DrawAttributes,-                                             Tree (..), groupChildren,-                                             patternElements, markerElements,-                                             maskContent, clipPathContent,+import           Graphics.SvgTree.Types     (Document (..),+                                             Tree (..), clipPathContent,+                                             groupChildren, markerElements,+                                             maskContent, patternElements,                                              preRendered) import           Graphics.SvgTree.XmlParser-import           Text.XML.Light+import           Text.XML.Light             hiding (showAttr)  ppDocument :: Document -> String ppDocument doc =@@ -54,5 +53,6 @@ tagStart           :: QName -> [Attr] -> ShowS tagStart qn as rs   = '<':showQName qn ++ as_str ++ rs  where as_str       = if null as then "" else ' ' : unwords (map showAttr as)-       showAttr           :: Attr -> String-       showAttr (Attr qn v) = showQName qn ++ '=' : '"' : v ++ "\""++showAttr           :: Attr -> String+showAttr (Attr qn v) = showQName qn ++ '=' : '"' : v ++ "\""
src/Graphics/SvgTree/Types.hs view
@@ -216,7 +216,6 @@ import qualified Data.Foldable             as F import           Data.Function             (on) import           Data.List                 (inits)-import qualified Data.Map                  as M import           Data.Monoid               (Last (..)) import           Data.Semigroup            (Semigroup (..)) import qualified Data.Text                 as T@@ -1628,6 +1627,7 @@     | MarkerTree    !Marker     | MaskTree      !Mask     | ClipPathTree  !ClipPath+    | SvgTree       !Document     deriving (Eq, Show)  data FilterElement@@ -1916,6 +1916,7 @@   dig prev e@(MarkerTree _) = f $ appNode prev e   dig prev e@(MaskTree _) = f $ appNode prev e   dig prev e@(ClipPathTree _) = f $ appNode prev e+  dig prev e@(SvgTree _) = f $ appNode prev e     zipGroup prev g = g { _groupChildren = updatedChildren }@@ -1951,6 +1952,7 @@     FilterTree _         -> f acc e     GroupTree g          -> foldGroup g     SymbolTree s         -> foldGroup (_groupOfSymbol s)+    SvgTree{}            -> f acc e     where       foldGroup g =         let subAcc = F.foldl' go acc $ _groupChildren g in@@ -1983,6 +1985,7 @@   go e@(MarkerTree _) = f e   go e@(MaskTree _) = f e   go e@(ClipPathTree _) = f e+  go e@SvgTree{} = f e    mapGroup g =       g { _groupChildren = map go $ _groupChildren g }@@ -2014,6 +2017,7 @@    MarkerTree _         -> "marker"    MaskTree _           -> "mask"    ClipPathTree _       -> "clipPath"+   SvgTree{}            -> "svg"  drawAttrOfTree :: Tree -> DrawAttributes drawAttrOfTree v = case v of@@ -2039,6 +2043,7 @@   MarkerTree e         -> e ^. drawAttributes   MaskTree e           -> e ^. drawAttributes   ClipPathTree e       -> e ^. drawAttributes+  SvgTree _            -> mempty -- FIXME  setDrawAttrOfTree :: Tree -> DrawAttributes -> Tree setDrawAttrOfTree v attr' = case v of@@ -2064,6 +2069,7 @@   MarkerTree e         -> MarkerTree $ e & drawAttributes .~ attr   MaskTree e           -> MaskTree $ e & drawAttributes .~ attr   ClipPathTree e       -> ClipPathTree $ e & drawAttributes .~ attr+  SvgTree e            -> SvgTree e   where     attr = attr'{_preRendered = Nothing} @@ -2545,12 +2551,11 @@     , _width            :: Maybe Number     , _height           :: Maybe Number     , _elements         :: [Tree]-    , _definitions      :: M.Map String Tree     , _description      :: String     , _documentLocation :: FilePath     , _documentAspectRatio :: PreserveAspectRatio     }-    deriving Show+    deriving (Show, Eq)   -- | Lenses associated to a SVG document.
src/Graphics/SvgTree/XmlParser.hs view
@@ -35,7 +35,6 @@ import           Control.Lens.Unsound import           Data.Attoparsec.Text         (Parser, parseOnly, string) import           Data.List                    (foldl', intercalate)-import qualified Data.Map                     as M import           Data.Maybe                   (catMaybes, fromMaybe) import           Data.Monoid                  (Last (Last), getLast, (<>)) import qualified Data.Text                    as T@@ -852,6 +851,7 @@        pathNode <- serializeTreeNode p        let sub = [X.Elem . setChildren pathNode $ X.elContent textNode]        return $ setChildren textNode sub+    SvgTree doc -> Just $ xmlOfDocument doc   isNotNone :: Tree -> Bool@@ -903,6 +903,8 @@       FEColorMatrix m  -> serializeTreeNode m       FEComposite c    -> serializeTreeNode c       FEGaussianBlur b -> serializeTreeNode b+      _                -> error $+        "Unsupported element: " ++ show fe ++ ". Please submit bug on github."   attributes =     [ "result" `parseIn` (filterAttributes . filterResult)] @@ -1189,6 +1191,10 @@     groupNode = _groupOfSymbol $ xmlUnparseWithDrawAttr e unparse e@(nodeName -> "g") =   GroupTree $ xmlUnparseWithDrawAttr e & groupChildren .~ map unparse (elChildren e)+unparse e@(nodeName -> "svg") =+  case unparseDocument "" e of+    Nothing -> None+    Just doc -> SvgTree doc unparse e@(nodeName -> "text") =   TextTree tPath $ xmlUnparse e & textRoot .~ root     where@@ -1228,7 +1234,6 @@     , _elements = parsedElements     , _width = lengthFind "width"     , _height = lengthFind "height"-    , _definitions = defs     , _description = ""     , _documentLocation = rootLocation     , _documentAspectRatio =@@ -1237,11 +1242,6 @@     }   where     parsedElements = map unparse $ elChildren e-    defs = foldl' (foldTree worker) M.empty parsedElements-    worker m t =-      case t ^.drawAttributes.attrId of-        Nothing  -> m-        Just tid -> M.insert tid t m     lengthFind n =         attributeFinder n e >>= parse complexNumber unparseDocument _ _ = Nothing