reanimate-svg 0.11.0.0 → 0.12.0.0
raw patch · 8 files changed
+1273/−64 lines, 8 filesdep +Diffdep +QuickCheckdep +directorydep ~basedep ~bytestringdep ~linearPVP ok
version bump matches the API change (PVP)
Dependencies added: Diff, QuickCheck, directory, filepath, process, reanimate-svg, tasty, tasty-expected-failure, tasty-golden, tasty-hunit, tasty-quickcheck, tasty-rerun, temporary
Dependency ranges changed: base, bytestring, linear, text, vector
API changes (from Hackage documentation)
+ Graphics.SvgTree: parseSvg :: Text -> Tree
+ Graphics.SvgTree.Types: Blend :: !DrawAttributes -> !FilterAttributes -> !Last FilterSource -> !Last FilterSource -> !BlendMode -> Blend
+ Graphics.SvgTree.Types: Color :: BlendMode
+ Graphics.SvgTree.Types: ColorBurn :: BlendMode
+ Graphics.SvgTree.Types: ColorDodge :: BlendMode
+ Graphics.SvgTree.Types: ComponentTransfer :: !DrawAttributes -> !FilterAttributes -> ![FilterElement] -> !Last FilterSource -> ComponentTransfer
+ Graphics.SvgTree.Types: ConvolveMatrix :: DrawAttributes -> !FilterAttributes -> !Last FilterSource -> NumberOptionalNumber -> [Double] -> Double -> Double -> Int -> Int -> EdgeMode -> NumberOptionalNumber -> Bool -> ConvolveMatrix
+ Graphics.SvgTree.Types: Darken :: BlendMode
+ Graphics.SvgTree.Types: Difference :: BlendMode
+ Graphics.SvgTree.Types: DropShadow :: DrawAttributes -> !FilterAttributes -> Double -> Double -> NumberOptionalNumber -> DropShadow
+ Graphics.SvgTree.Types: Exclusion :: BlendMode
+ Graphics.SvgTree.Types: FDiscrete :: FuncType
+ Graphics.SvgTree.Types: FGamma :: FuncType
+ Graphics.SvgTree.Types: FIdentity :: FuncType
+ Graphics.SvgTree.Types: FLinear :: FuncType
+ Graphics.SvgTree.Types: FTable :: FuncType
+ Graphics.SvgTree.Types: Flood :: !DrawAttributes -> !FilterAttributes -> !PixelRGBA8 -> !Maybe Double -> Flood
+ Graphics.SvgTree.Types: FuncA :: !DrawAttributes -> !FuncType -> ![Number] -> !Number -> !Number -> !Number -> !Number -> FuncA
+ Graphics.SvgTree.Types: FuncB :: !DrawAttributes -> !FuncType -> ![Number] -> !Number -> !Number -> !Number -> !Number -> FuncB
+ Graphics.SvgTree.Types: FuncG :: !DrawAttributes -> !FuncType -> ![Number] -> !Number -> !Number -> !Number -> !Number -> FuncG
+ Graphics.SvgTree.Types: FuncR :: !DrawAttributes -> !FuncType -> ![Number] -> !Number -> !Number -> !Number -> !Number -> FuncR
+ Graphics.SvgTree.Types: HardLight :: BlendMode
+ Graphics.SvgTree.Types: Hue :: BlendMode
+ Graphics.SvgTree.Types: ImageF :: DrawAttributes -> !FilterAttributes -> !String -> !PreserveAspectRatio -> ImageF
+ Graphics.SvgTree.Types: Lighten :: BlendMode
+ Graphics.SvgTree.Types: Luminosity :: BlendMode
+ Graphics.SvgTree.Types: Merge :: !DrawAttributes -> !FilterAttributes -> ![FilterElement] -> Merge
+ Graphics.SvgTree.Types: MergeNode :: !DrawAttributes -> !Last FilterSource -> MergeNode
+ Graphics.SvgTree.Types: Morphology :: DrawAttributes -> !FilterAttributes -> !Last FilterSource -> OperatorType -> NumberOptionalNumber -> Morphology
+ Graphics.SvgTree.Types: Multiply :: BlendMode
+ Graphics.SvgTree.Types: Normal :: BlendMode
+ Graphics.SvgTree.Types: Num1 :: Double -> NumberOptionalNumber
+ Graphics.SvgTree.Types: Num2 :: Double -> Double -> NumberOptionalNumber
+ Graphics.SvgTree.Types: Offset :: !DrawAttributes -> !FilterAttributes -> !Last FilterSource -> !Number -> !Number -> Offset
+ Graphics.SvgTree.Types: OperatorArithmetic :: OperatorType
+ Graphics.SvgTree.Types: OperatorAtop :: OperatorType
+ Graphics.SvgTree.Types: OperatorIn :: OperatorType
+ Graphics.SvgTree.Types: OperatorLighter :: OperatorType
+ Graphics.SvgTree.Types: OperatorOut :: OperatorType
+ Graphics.SvgTree.Types: OperatorOver :: OperatorType
+ Graphics.SvgTree.Types: OperatorXor :: OperatorType
+ Graphics.SvgTree.Types: Overlay :: BlendMode
+ Graphics.SvgTree.Types: Saturation :: BlendMode
+ Graphics.SvgTree.Types: Screen :: BlendMode
+ Graphics.SvgTree.Types: SoftLight :: BlendMode
+ Graphics.SvgTree.Types: SpecularLighting :: DrawAttributes -> !FilterAttributes -> !Last FilterSource -> Double -> Double -> Double -> NumberOptionalNumber -> SpecularLighting
+ Graphics.SvgTree.Types: Tile :: !DrawAttributes -> !FilterAttributes -> !Last FilterSource -> Tile
+ Graphics.SvgTree.Types: [_blendDrawAttributes] :: Blend -> !DrawAttributes
+ Graphics.SvgTree.Types: [_blendFilterAttr] :: Blend -> !FilterAttributes
+ Graphics.SvgTree.Types: [_blendIn2] :: Blend -> !Last FilterSource
+ Graphics.SvgTree.Types: [_blendIn] :: Blend -> !Last FilterSource
+ Graphics.SvgTree.Types: [_blendMode] :: Blend -> !BlendMode
+ Graphics.SvgTree.Types: [_compTransferChildren] :: ComponentTransfer -> ![FilterElement]
+ Graphics.SvgTree.Types: [_compTransferDrawAttributes] :: ComponentTransfer -> !DrawAttributes
+ Graphics.SvgTree.Types: [_compTransferFilterAttr] :: ComponentTransfer -> !FilterAttributes
+ Graphics.SvgTree.Types: [_compTransferIn] :: ComponentTransfer -> !Last FilterSource
+ Graphics.SvgTree.Types: [_convolveMatrixBias] :: ConvolveMatrix -> Double
+ Graphics.SvgTree.Types: [_convolveMatrixDivisor] :: ConvolveMatrix -> Double
+ Graphics.SvgTree.Types: [_convolveMatrixDrawAttributes] :: ConvolveMatrix -> DrawAttributes
+ Graphics.SvgTree.Types: [_convolveMatrixEdgeMode] :: ConvolveMatrix -> EdgeMode
+ Graphics.SvgTree.Types: [_convolveMatrixFilterAttr] :: ConvolveMatrix -> !FilterAttributes
+ Graphics.SvgTree.Types: [_convolveMatrixIn] :: ConvolveMatrix -> !Last FilterSource
+ Graphics.SvgTree.Types: [_convolveMatrixKernelMatrix] :: ConvolveMatrix -> [Double]
+ Graphics.SvgTree.Types: [_convolveMatrixKernelUnitLength] :: ConvolveMatrix -> NumberOptionalNumber
+ Graphics.SvgTree.Types: [_convolveMatrixOrder] :: ConvolveMatrix -> NumberOptionalNumber
+ Graphics.SvgTree.Types: [_convolveMatrixPreserveAlpha] :: ConvolveMatrix -> Bool
+ Graphics.SvgTree.Types: [_convolveMatrixTargetX] :: ConvolveMatrix -> Int
+ Graphics.SvgTree.Types: [_convolveMatrixTargetY] :: ConvolveMatrix -> Int
+ Graphics.SvgTree.Types: [_dropShadowDrawAttributes] :: DropShadow -> DrawAttributes
+ Graphics.SvgTree.Types: [_dropShadowDx] :: DropShadow -> Double
+ Graphics.SvgTree.Types: [_dropShadowDy] :: DropShadow -> Double
+ Graphics.SvgTree.Types: [_dropShadowFilterAttr] :: DropShadow -> !FilterAttributes
+ Graphics.SvgTree.Types: [_dropShadowStdDeviation] :: DropShadow -> NumberOptionalNumber
+ Graphics.SvgTree.Types: [_floodColor] :: Flood -> !PixelRGBA8
+ Graphics.SvgTree.Types: [_floodDrawAttributes] :: Flood -> !DrawAttributes
+ Graphics.SvgTree.Types: [_floodFilterAttr] :: Flood -> !FilterAttributes
+ Graphics.SvgTree.Types: [_floodOpacity] :: Flood -> !Maybe Double
+ Graphics.SvgTree.Types: [_funcAAmplitude] :: FuncA -> !Number
+ Graphics.SvgTree.Types: [_funcADrawAttributes] :: FuncA -> !DrawAttributes
+ Graphics.SvgTree.Types: [_funcAExponent] :: FuncA -> !Number
+ Graphics.SvgTree.Types: [_funcAIntercept] :: FuncA -> !Number
+ Graphics.SvgTree.Types: [_funcASlope] :: FuncA -> !Number
+ Graphics.SvgTree.Types: [_funcATableValues] :: FuncA -> ![Number]
+ Graphics.SvgTree.Types: [_funcAType] :: FuncA -> !FuncType
+ Graphics.SvgTree.Types: [_funcBAmplitude] :: FuncB -> !Number
+ Graphics.SvgTree.Types: [_funcBDrawAttributes] :: FuncB -> !DrawAttributes
+ Graphics.SvgTree.Types: [_funcBExponent] :: FuncB -> !Number
+ Graphics.SvgTree.Types: [_funcBIntercept] :: FuncB -> !Number
+ Graphics.SvgTree.Types: [_funcBSlope] :: FuncB -> !Number
+ Graphics.SvgTree.Types: [_funcBTableValues] :: FuncB -> ![Number]
+ Graphics.SvgTree.Types: [_funcBType] :: FuncB -> !FuncType
+ Graphics.SvgTree.Types: [_funcGAmplitude] :: FuncG -> !Number
+ Graphics.SvgTree.Types: [_funcGDrawAttributes] :: FuncG -> !DrawAttributes
+ Graphics.SvgTree.Types: [_funcGExponent] :: FuncG -> !Number
+ Graphics.SvgTree.Types: [_funcGIntercept] :: FuncG -> !Number
+ Graphics.SvgTree.Types: [_funcGSlope] :: FuncG -> !Number
+ Graphics.SvgTree.Types: [_funcGTableValues] :: FuncG -> ![Number]
+ Graphics.SvgTree.Types: [_funcGType] :: FuncG -> !FuncType
+ Graphics.SvgTree.Types: [_funcRAmplitude] :: FuncR -> !Number
+ Graphics.SvgTree.Types: [_funcRDrawAttributes] :: FuncR -> !DrawAttributes
+ Graphics.SvgTree.Types: [_funcRExponent] :: FuncR -> !Number
+ Graphics.SvgTree.Types: [_funcRIntercept] :: FuncR -> !Number
+ Graphics.SvgTree.Types: [_funcRSlope] :: FuncR -> !Number
+ Graphics.SvgTree.Types: [_funcRTableValues] :: FuncR -> ![Number]
+ Graphics.SvgTree.Types: [_funcRType] :: FuncR -> !FuncType
+ Graphics.SvgTree.Types: [_imageFAspectRatio] :: ImageF -> !PreserveAspectRatio
+ Graphics.SvgTree.Types: [_imageFDrawAttributes] :: ImageF -> DrawAttributes
+ Graphics.SvgTree.Types: [_imageFFilterAttr] :: ImageF -> !FilterAttributes
+ Graphics.SvgTree.Types: [_imageFHref] :: ImageF -> !String
+ Graphics.SvgTree.Types: [_mergeChildren] :: Merge -> ![FilterElement]
+ Graphics.SvgTree.Types: [_mergeDrawAttributes] :: Merge -> !DrawAttributes
+ Graphics.SvgTree.Types: [_mergeFilterAttributes] :: Merge -> !FilterAttributes
+ Graphics.SvgTree.Types: [_mergeNodeDrawAttributes] :: MergeNode -> !DrawAttributes
+ Graphics.SvgTree.Types: [_mergeNodeIn] :: MergeNode -> !Last FilterSource
+ Graphics.SvgTree.Types: [_morphologyDrawAttributes] :: Morphology -> DrawAttributes
+ Graphics.SvgTree.Types: [_morphologyFilterAttr] :: Morphology -> !FilterAttributes
+ Graphics.SvgTree.Types: [_morphologyIn] :: Morphology -> !Last FilterSource
+ Graphics.SvgTree.Types: [_morphologyOperator] :: Morphology -> OperatorType
+ Graphics.SvgTree.Types: [_morphologyRadius] :: Morphology -> NumberOptionalNumber
+ Graphics.SvgTree.Types: [_offsetDX] :: Offset -> !Number
+ Graphics.SvgTree.Types: [_offsetDY] :: Offset -> !Number
+ Graphics.SvgTree.Types: [_offsetDrawAttributes] :: Offset -> !DrawAttributes
+ Graphics.SvgTree.Types: [_offsetFilterAttr] :: Offset -> !FilterAttributes
+ Graphics.SvgTree.Types: [_offsetIn] :: Offset -> !Last FilterSource
+ Graphics.SvgTree.Types: [_specLightingDrawAttributes] :: SpecularLighting -> DrawAttributes
+ Graphics.SvgTree.Types: [_specLightingFilterAttr] :: SpecularLighting -> !FilterAttributes
+ Graphics.SvgTree.Types: [_specLightingIn] :: SpecularLighting -> !Last FilterSource
+ Graphics.SvgTree.Types: [_specLightingKernelUnitLength] :: SpecularLighting -> NumberOptionalNumber
+ Graphics.SvgTree.Types: [_specLightingSpecularConst] :: SpecularLighting -> Double
+ Graphics.SvgTree.Types: [_specLightingSpecularExp] :: SpecularLighting -> Double
+ Graphics.SvgTree.Types: [_specLightingSurfaceScale] :: SpecularLighting -> Double
+ Graphics.SvgTree.Types: [_tileDrawAttributes] :: Tile -> !DrawAttributes
+ Graphics.SvgTree.Types: [_tileFilterAttr] :: Tile -> !FilterAttributes
+ Graphics.SvgTree.Types: [_tileIn] :: Tile -> !Last FilterSource
+ Graphics.SvgTree.Types: blendDrawAttributes :: Lens' Blend DrawAttributes
+ Graphics.SvgTree.Types: blendFilterAttr :: Lens' Blend FilterAttributes
+ Graphics.SvgTree.Types: blendIn :: Lens' Blend (Last FilterSource)
+ Graphics.SvgTree.Types: blendIn2 :: Lens' Blend (Last FilterSource)
+ Graphics.SvgTree.Types: blendMode :: Lens' Blend BlendMode
+ Graphics.SvgTree.Types: compTransferChildren :: Lens' ComponentTransfer [FilterElement]
+ Graphics.SvgTree.Types: compTransferDrawAttributes :: Lens' ComponentTransfer DrawAttributes
+ Graphics.SvgTree.Types: compTransferFilterAttr :: Lens' ComponentTransfer FilterAttributes
+ Graphics.SvgTree.Types: compTransferIn :: Lens' ComponentTransfer (Last FilterSource)
+ Graphics.SvgTree.Types: convolveMatrixBias :: Lens' ConvolveMatrix Double
+ Graphics.SvgTree.Types: convolveMatrixDivisor :: Lens' ConvolveMatrix Double
+ Graphics.SvgTree.Types: convolveMatrixDrawAttributes :: Lens' ConvolveMatrix DrawAttributes
+ Graphics.SvgTree.Types: convolveMatrixEdgeMode :: Lens' ConvolveMatrix EdgeMode
+ Graphics.SvgTree.Types: convolveMatrixFilterAttr :: Lens' ConvolveMatrix FilterAttributes
+ Graphics.SvgTree.Types: convolveMatrixIn :: Lens' ConvolveMatrix (Last FilterSource)
+ Graphics.SvgTree.Types: convolveMatrixKernelMatrix :: Lens' ConvolveMatrix [Double]
+ Graphics.SvgTree.Types: convolveMatrixKernelUnitLength :: Lens' ConvolveMatrix NumberOptionalNumber
+ Graphics.SvgTree.Types: convolveMatrixOrder :: Lens' ConvolveMatrix NumberOptionalNumber
+ Graphics.SvgTree.Types: convolveMatrixPreserveAlpha :: Lens' ConvolveMatrix Bool
+ Graphics.SvgTree.Types: convolveMatrixTargetX :: Lens' ConvolveMatrix Int
+ Graphics.SvgTree.Types: convolveMatrixTargetY :: Lens' ConvolveMatrix Int
+ Graphics.SvgTree.Types: data Blend
+ Graphics.SvgTree.Types: data BlendMode
+ Graphics.SvgTree.Types: data ComponentTransfer
+ Graphics.SvgTree.Types: data ConvolveMatrix
+ Graphics.SvgTree.Types: data DiffuseLighting
+ Graphics.SvgTree.Types: data DropShadow
+ Graphics.SvgTree.Types: data Flood
+ Graphics.SvgTree.Types: data FuncA
+ Graphics.SvgTree.Types: data FuncB
+ Graphics.SvgTree.Types: data FuncG
+ Graphics.SvgTree.Types: data FuncR
+ Graphics.SvgTree.Types: data FuncType
+ Graphics.SvgTree.Types: data ImageF
+ Graphics.SvgTree.Types: data Merge
+ Graphics.SvgTree.Types: data MergeNode
+ Graphics.SvgTree.Types: data Morphology
+ Graphics.SvgTree.Types: data NumberOptionalNumber
+ Graphics.SvgTree.Types: data Offset
+ Graphics.SvgTree.Types: data OperatorType
+ Graphics.SvgTree.Types: data SpecularLighting
+ Graphics.SvgTree.Types: data Tile
+ Graphics.SvgTree.Types: diffuseLightingDiffuseConst :: Lens' DiffuseLighting Double
+ Graphics.SvgTree.Types: diffuseLightingDrawAttributes :: Lens' DiffuseLighting DrawAttributes
+ Graphics.SvgTree.Types: diffuseLightingFilterAttr :: Lens' DiffuseLighting FilterAttributes
+ Graphics.SvgTree.Types: diffuseLightingIn :: Lens' DiffuseLighting (Last FilterSource)
+ Graphics.SvgTree.Types: diffuseLightingKernelUnitLength :: Lens' DiffuseLighting NumberOptionalNumber
+ Graphics.SvgTree.Types: diffuseLightingSurfaceScale :: Lens' DiffuseLighting Double
+ Graphics.SvgTree.Types: dropShadowDrawAttributes :: Lens' DropShadow DrawAttributes
+ Graphics.SvgTree.Types: dropShadowDx :: Lens' DropShadow Double
+ Graphics.SvgTree.Types: dropShadowDy :: Lens' DropShadow Double
+ Graphics.SvgTree.Types: dropShadowFilterAttr :: Lens' DropShadow FilterAttributes
+ Graphics.SvgTree.Types: dropShadowStdDeviation :: Lens' DropShadow NumberOptionalNumber
+ Graphics.SvgTree.Types: floodColor :: Lens' Flood PixelRGBA8
+ Graphics.SvgTree.Types: floodDrawAttributes :: Lens' Flood DrawAttributes
+ Graphics.SvgTree.Types: floodFilterAttr :: Lens' Flood FilterAttributes
+ Graphics.SvgTree.Types: floodOpacity :: Lens' Flood (Maybe Double)
+ Graphics.SvgTree.Types: funcAAmplitude :: Lens' FuncA Number
+ Graphics.SvgTree.Types: funcADrawAttributes :: Lens' FuncA DrawAttributes
+ Graphics.SvgTree.Types: funcAExponent :: Lens' FuncA Number
+ Graphics.SvgTree.Types: funcAIntercept :: Lens' FuncA Number
+ Graphics.SvgTree.Types: funcASlope :: Lens' FuncA Number
+ Graphics.SvgTree.Types: funcATableValues :: Lens' FuncA [Number]
+ Graphics.SvgTree.Types: funcAType :: Lens' FuncA FuncType
+ Graphics.SvgTree.Types: funcBAmplitude :: Lens' FuncB Number
+ Graphics.SvgTree.Types: funcBDrawAttributes :: Lens' FuncB DrawAttributes
+ Graphics.SvgTree.Types: funcBExponent :: Lens' FuncB Number
+ Graphics.SvgTree.Types: funcBIntercept :: Lens' FuncB Number
+ Graphics.SvgTree.Types: funcBSlope :: Lens' FuncB Number
+ Graphics.SvgTree.Types: funcBTableValues :: Lens' FuncB [Number]
+ Graphics.SvgTree.Types: funcBType :: Lens' FuncB FuncType
+ Graphics.SvgTree.Types: funcGAmplitude :: Lens' FuncG Number
+ Graphics.SvgTree.Types: funcGDrawAttributes :: Lens' FuncG DrawAttributes
+ Graphics.SvgTree.Types: funcGExponent :: Lens' FuncG Number
+ Graphics.SvgTree.Types: funcGIntercept :: Lens' FuncG Number
+ Graphics.SvgTree.Types: funcGSlope :: Lens' FuncG Number
+ Graphics.SvgTree.Types: funcGTableValues :: Lens' FuncG [Number]
+ Graphics.SvgTree.Types: funcGType :: Lens' FuncG FuncType
+ Graphics.SvgTree.Types: funcRAmplitude :: Lens' FuncR Number
+ Graphics.SvgTree.Types: funcRDrawAttributes :: Lens' FuncR DrawAttributes
+ Graphics.SvgTree.Types: funcRExponent :: Lens' FuncR Number
+ Graphics.SvgTree.Types: funcRIntercept :: Lens' FuncR Number
+ Graphics.SvgTree.Types: funcRSlope :: Lens' FuncR Number
+ Graphics.SvgTree.Types: funcRTableValues :: Lens' FuncR [Number]
+ Graphics.SvgTree.Types: funcRType :: Lens' FuncR FuncType
+ Graphics.SvgTree.Types: imageFAspectRatio :: Lens' ImageF PreserveAspectRatio
+ Graphics.SvgTree.Types: imageFDrawAttributes :: Lens' ImageF DrawAttributes
+ Graphics.SvgTree.Types: imageFFilterAttr :: Lens' ImageF FilterAttributes
+ Graphics.SvgTree.Types: imageFHref :: Lens' ImageF String
+ Graphics.SvgTree.Types: mergeChildren :: Lens' Merge [FilterElement]
+ Graphics.SvgTree.Types: mergeDrawAttributes :: Lens' Merge DrawAttributes
+ Graphics.SvgTree.Types: mergeFilterAttributes :: Lens' Merge FilterAttributes
+ Graphics.SvgTree.Types: mergeNodeDrawAttributes :: Lens' MergeNode DrawAttributes
+ Graphics.SvgTree.Types: mergeNodeIn :: Lens' MergeNode (Last FilterSource)
+ Graphics.SvgTree.Types: morphologyDrawAttributes :: Lens' Morphology DrawAttributes
+ Graphics.SvgTree.Types: morphologyFilterAttr :: Lens' Morphology FilterAttributes
+ Graphics.SvgTree.Types: morphologyIn :: Lens' Morphology (Last FilterSource)
+ Graphics.SvgTree.Types: morphologyOperator :: Lens' Morphology OperatorType
+ Graphics.SvgTree.Types: morphologyRadius :: Lens' Morphology NumberOptionalNumber
+ Graphics.SvgTree.Types: offsetDX :: Lens' Offset Number
+ Graphics.SvgTree.Types: offsetDY :: Lens' Offset Number
+ Graphics.SvgTree.Types: offsetDrawAttributes :: Lens' Offset DrawAttributes
+ Graphics.SvgTree.Types: offsetFilterAttr :: Lens' Offset FilterAttributes
+ Graphics.SvgTree.Types: offsetIn :: Lens' Offset (Last FilterSource)
+ Graphics.SvgTree.Types: specLightingDrawAttributes :: Lens' SpecularLighting DrawAttributes
+ Graphics.SvgTree.Types: specLightingFilterAttr :: Lens' SpecularLighting FilterAttributes
+ Graphics.SvgTree.Types: specLightingIn :: Lens' SpecularLighting (Last FilterSource)
+ Graphics.SvgTree.Types: specLightingKernelUnitLength :: Lens' SpecularLighting NumberOptionalNumber
+ Graphics.SvgTree.Types: specLightingSpecularConst :: Lens' SpecularLighting Double
+ Graphics.SvgTree.Types: specLightingSpecularExp :: Lens' SpecularLighting Double
+ Graphics.SvgTree.Types: specLightingSurfaceScale :: Lens' SpecularLighting Double
+ Graphics.SvgTree.Types: tileDrawAttributes :: Lens' Tile DrawAttributes
+ Graphics.SvgTree.Types: tileFilterAttr :: Lens' Tile FilterAttributes
+ Graphics.SvgTree.Types: tileIn :: Lens' Tile (Last FilterSource)
- Graphics.SvgTree.Types: FEBlend :: FilterElement
+ Graphics.SvgTree.Types: FEBlend :: Blend -> FilterElement
- Graphics.SvgTree.Types: FEComponentTransfer :: FilterElement
+ Graphics.SvgTree.Types: FEComponentTransfer :: ComponentTransfer -> FilterElement
- Graphics.SvgTree.Types: FEConvolveMatrix :: FilterElement
+ Graphics.SvgTree.Types: FEConvolveMatrix :: ConvolveMatrix -> FilterElement
- Graphics.SvgTree.Types: FEDiffuseLighting :: FilterElement
+ Graphics.SvgTree.Types: FEDiffuseLighting :: DiffuseLighting -> FilterElement
- Graphics.SvgTree.Types: FEDropShadow :: FilterElement
+ Graphics.SvgTree.Types: FEDropShadow :: DropShadow -> FilterElement
- Graphics.SvgTree.Types: FEFlood :: FilterElement
+ Graphics.SvgTree.Types: FEFlood :: Flood -> FilterElement
- Graphics.SvgTree.Types: FEFuncA :: FilterElement
+ Graphics.SvgTree.Types: FEFuncA :: FuncA -> FilterElement
- Graphics.SvgTree.Types: FEFuncB :: FilterElement
+ Graphics.SvgTree.Types: FEFuncB :: FuncB -> FilterElement
- Graphics.SvgTree.Types: FEFuncG :: FilterElement
+ Graphics.SvgTree.Types: FEFuncG :: FuncG -> FilterElement
- Graphics.SvgTree.Types: FEFuncR :: FilterElement
+ Graphics.SvgTree.Types: FEFuncR :: FuncR -> FilterElement
- Graphics.SvgTree.Types: FEImage :: FilterElement
+ Graphics.SvgTree.Types: FEImage :: ImageF -> FilterElement
- Graphics.SvgTree.Types: FEMerge :: FilterElement
+ Graphics.SvgTree.Types: FEMerge :: Merge -> FilterElement
- Graphics.SvgTree.Types: FEMergeNode :: FilterElement
+ Graphics.SvgTree.Types: FEMergeNode :: MergeNode -> FilterElement
- Graphics.SvgTree.Types: FEMorphology :: FilterElement
+ Graphics.SvgTree.Types: FEMorphology :: Morphology -> FilterElement
- Graphics.SvgTree.Types: FEOffset :: FilterElement
+ Graphics.SvgTree.Types: FEOffset :: Offset -> FilterElement
- Graphics.SvgTree.Types: FESpecularLighting :: FilterElement
+ Graphics.SvgTree.Types: FESpecularLighting :: SpecularLighting -> FilterElement
- Graphics.SvgTree.Types: FETile :: FilterElement
+ Graphics.SvgTree.Types: FETile :: Tile -> FilterElement
- Graphics.SvgTree.Types: attrClass :: HasDrawAttributes c_avt9 => Lens' c_avt9 [Text]
+ Graphics.SvgTree.Types: attrClass :: HasDrawAttributes c_avvw => Lens' c_avvw [Text]
- Graphics.SvgTree.Types: attrId :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Maybe String)
+ Graphics.SvgTree.Types: attrId :: HasDrawAttributes c_avvw => Lens' c_avvw (Maybe String)
- Graphics.SvgTree.Types: class HasDrawAttributes c_avt9
+ Graphics.SvgTree.Types: class HasDrawAttributes c_avvw
- Graphics.SvgTree.Types: class HasFilterAttributes c_aDzl
+ Graphics.SvgTree.Types: class HasFilterAttributes c_aGMB
- Graphics.SvgTree.Types: clipPathRef :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last ElementRef)
+ Graphics.SvgTree.Types: clipPathRef :: HasDrawAttributes c_avvw => Lens' c_avvw (Last ElementRef)
- Graphics.SvgTree.Types: clipRule :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last FillRule)
+ Graphics.SvgTree.Types: clipRule :: HasDrawAttributes c_avvw => Lens' c_avvw (Last FillRule)
- Graphics.SvgTree.Types: drawAttributes :: HasDrawAttributes c_avt9 => Lens' c_avt9 DrawAttributes
+ Graphics.SvgTree.Types: drawAttributes :: HasDrawAttributes c_avvw => Lens' c_avvw DrawAttributes
- Graphics.SvgTree.Types: fillColor :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last Texture)
+ Graphics.SvgTree.Types: fillColor :: HasDrawAttributes c_avvw => Lens' c_avvw (Last Texture)
- Graphics.SvgTree.Types: fillOpacity :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Maybe Float)
+ Graphics.SvgTree.Types: fillOpacity :: HasDrawAttributes c_avvw => Lens' c_avvw (Maybe Float)
- Graphics.SvgTree.Types: fillRule :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last FillRule)
+ Graphics.SvgTree.Types: fillRule :: HasDrawAttributes c_avvw => Lens' c_avvw (Last FillRule)
- Graphics.SvgTree.Types: filterAttributes :: HasFilterAttributes c_aDzl => Lens' c_aDzl FilterAttributes
+ Graphics.SvgTree.Types: filterAttributes :: HasFilterAttributes c_aGMB => Lens' c_aGMB FilterAttributes
- Graphics.SvgTree.Types: filterHeight :: HasFilterAttributes c_aDzl => Lens' c_aDzl (Last Number)
+ Graphics.SvgTree.Types: filterHeight :: HasFilterAttributes c_aGMB => Lens' c_aGMB (Last Number)
- Graphics.SvgTree.Types: filterRef :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last ElementRef)
+ Graphics.SvgTree.Types: filterRef :: HasDrawAttributes c_avvw => Lens' c_avvw (Last ElementRef)
- Graphics.SvgTree.Types: filterResult :: HasFilterAttributes c_aDzl => Lens' c_aDzl (Maybe String)
+ Graphics.SvgTree.Types: filterResult :: HasFilterAttributes c_aGMB => Lens' c_aGMB (Maybe String)
- Graphics.SvgTree.Types: filterWidth :: HasFilterAttributes c_aDzl => Lens' c_aDzl (Last Number)
+ Graphics.SvgTree.Types: filterWidth :: HasFilterAttributes c_aGMB => Lens' c_aGMB (Last Number)
- Graphics.SvgTree.Types: filterX :: HasFilterAttributes c_aDzl => Lens' c_aDzl (Last Number)
+ Graphics.SvgTree.Types: filterX :: HasFilterAttributes c_aGMB => Lens' c_aGMB (Last Number)
- Graphics.SvgTree.Types: filterY :: HasFilterAttributes c_aDzl => Lens' c_aDzl (Last Number)
+ Graphics.SvgTree.Types: filterY :: HasFilterAttributes c_aGMB => Lens' c_aGMB (Last Number)
- Graphics.SvgTree.Types: fontFamily :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last [String])
+ Graphics.SvgTree.Types: fontFamily :: HasDrawAttributes c_avvw => Lens' c_avvw (Last [String])
- Graphics.SvgTree.Types: fontSize :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last Number)
+ Graphics.SvgTree.Types: fontSize :: HasDrawAttributes c_avvw => Lens' c_avvw (Last Number)
- Graphics.SvgTree.Types: fontStyle :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last FontStyle)
+ Graphics.SvgTree.Types: fontStyle :: HasDrawAttributes c_avvw => Lens' c_avvw (Last FontStyle)
- Graphics.SvgTree.Types: groupOpacity :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Maybe Float)
+ Graphics.SvgTree.Types: groupOpacity :: HasDrawAttributes c_avvw => Lens' c_avvw (Maybe Float)
- Graphics.SvgTree.Types: markerEnd :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last ElementRef)
+ Graphics.SvgTree.Types: markerEnd :: HasDrawAttributes c_avvw => Lens' c_avvw (Last ElementRef)
- Graphics.SvgTree.Types: markerMid :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last ElementRef)
+ Graphics.SvgTree.Types: markerMid :: HasDrawAttributes c_avvw => Lens' c_avvw (Last ElementRef)
- Graphics.SvgTree.Types: markerStart :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last ElementRef)
+ Graphics.SvgTree.Types: markerStart :: HasDrawAttributes c_avvw => Lens' c_avvw (Last ElementRef)
- Graphics.SvgTree.Types: maskRef :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last ElementRef)
+ Graphics.SvgTree.Types: maskRef :: HasDrawAttributes c_avvw => Lens' c_avvw (Last ElementRef)
- Graphics.SvgTree.Types: strokeColor :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last Texture)
+ Graphics.SvgTree.Types: strokeColor :: HasDrawAttributes c_avvw => Lens' c_avvw (Last Texture)
- Graphics.SvgTree.Types: strokeDashArray :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last [Number])
+ Graphics.SvgTree.Types: strokeDashArray :: HasDrawAttributes c_avvw => Lens' c_avvw (Last [Number])
- Graphics.SvgTree.Types: strokeLineCap :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last Cap)
+ Graphics.SvgTree.Types: strokeLineCap :: HasDrawAttributes c_avvw => Lens' c_avvw (Last Cap)
- Graphics.SvgTree.Types: strokeLineJoin :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last LineJoin)
+ Graphics.SvgTree.Types: strokeLineJoin :: HasDrawAttributes c_avvw => Lens' c_avvw (Last LineJoin)
- Graphics.SvgTree.Types: strokeMiterLimit :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last Double)
+ Graphics.SvgTree.Types: strokeMiterLimit :: HasDrawAttributes c_avvw => Lens' c_avvw (Last Double)
- Graphics.SvgTree.Types: strokeOffset :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last Number)
+ Graphics.SvgTree.Types: strokeOffset :: HasDrawAttributes c_avvw => Lens' c_avvw (Last Number)
- Graphics.SvgTree.Types: strokeOpacity :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Maybe Float)
+ Graphics.SvgTree.Types: strokeOpacity :: HasDrawAttributes c_avvw => Lens' c_avvw (Maybe Float)
- Graphics.SvgTree.Types: strokeWidth :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last Number)
+ Graphics.SvgTree.Types: strokeWidth :: HasDrawAttributes c_avvw => Lens' c_avvw (Last Number)
- Graphics.SvgTree.Types: textAnchor :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Last TextAnchor)
+ Graphics.SvgTree.Types: textAnchor :: HasDrawAttributes c_avvw => Lens' c_avvw (Last TextAnchor)
- Graphics.SvgTree.Types: transform :: HasDrawAttributes c_avt9 => Lens' c_avt9 (Maybe [Transformation])
+ Graphics.SvgTree.Types: transform :: HasDrawAttributes c_avvw => Lens' c_avvw (Maybe [Transformation])
Files
- reanimate-svg.cabal +22/−1
- src/Graphics/SvgTree.hs +7/−0
- src/Graphics/SvgTree/Types.hs +129/−0
- src/Graphics/SvgTree/Types/Hashable.hs +33/−0
- src/Graphics/SvgTree/Types/Instances.hs +121/−34
- src/Graphics/SvgTree/Types/Internal.hs +563/−22
- src/Graphics/SvgTree/XmlParser.hs +313/−7
- test/W3C.hs +85/−0
reanimate-svg.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: reanimate-svg-version: 0.11.0.0+version: 0.12.0.0 synopsis: SVG file loader and serializer description: reanimate-svg provides types representing a SVG document,@@ -63,3 +63,24 @@ , lens >= 4.6 && < 5 , double-conversion >= 2.0.0.0 && < 3.0.0.0 , hashable >= 1.3.0.0++test-suite w3c-spec+ type: exitcode-stdio-1.0+ main-is: W3C.hs+ default-language: Haskell2010+ other-modules:+ hs-source-dirs: test+ ghc-options: -w+ build-depends:+ base,+ directory,+ filepath,+ bytestring, process,+ reanimate-svg,+ Diff,+ vector, linear,+ QuickCheck >= 2.1.0, text,+ temporary,+ tasty, tasty-golden, tasty-hunit,+ tasty-quickcheck, tasty-rerun >= 1.1.17,+ tasty-expected-failure
src/Graphics/SvgTree.hs view
@@ -4,6 +4,7 @@ ( -- * Saving/Loading functions loadSvgFile, parseSvgFile,+ parseSvg, unparse, xmlOfDocument, xmlOfTree,@@ -46,6 +47,12 @@ Maybe Document parseSvgFile filename fileContent = parseXMLDoc fileContent >>= unparseDocument filename++parseSvg :: T.Text -> Tree+parseSvg inp =+ case parseXMLDoc inp of+ Nothing -> error "Invalid XML"+ Just xml -> unparse xml -- | Save a svg Document on a file on disk. saveXmlFile :: FilePath -> Document -> IO ()
src/Graphics/SvgTree/Types.hs view
@@ -59,6 +59,135 @@ , FilterAttributes(..) , HasFilterAttributes(..) , FilterSource(..)++ , Blend (..)+ , BlendMode (..)+ , blendDrawAttributes+ , blendFilterAttr+ , blendIn+ , blendIn2+ , blendMode++ , ConvolveMatrix (..)+ , convolveMatrixDrawAttributes+ , convolveMatrixFilterAttr+ , convolveMatrixIn+ , convolveMatrixOrder+ , convolveMatrixKernelMatrix+ , convolveMatrixDivisor+ , convolveMatrixBias+ , convolveMatrixTargetX+ , convolveMatrixTargetY+ , convolveMatrixEdgeMode+ , convolveMatrixKernelUnitLength+ , convolveMatrixPreserveAlpha++ , Morphology (..)+ , OperatorType (..)+ , NumberOptionalNumber (..)+ , morphologyDrawAttributes+ , morphologyFilterAttr+ , morphologyIn+ , morphologyOperator+ , morphologyRadius++ , SpecularLighting (..)+ , specLightingDrawAttributes+ , specLightingFilterAttr+ , specLightingIn+ , specLightingSurfaceScale+ , specLightingSpecularConst+ , specLightingSpecularExp+ , specLightingKernelUnitLength++ , DiffuseLighting+ , diffuseLightingDrawAttributes+ , diffuseLightingFilterAttr+ , diffuseLightingIn+ , diffuseLightingSurfaceScale+ , diffuseLightingDiffuseConst+ , diffuseLightingKernelUnitLength++ , DropShadow (..)+ , dropShadowDrawAttributes+ , dropShadowFilterAttr+ , dropShadowDx+ , dropShadowDy+ , dropShadowStdDeviation++ , Flood (..)+ , floodDrawAttributes+ , floodFilterAttr+ , floodColor+ , floodOpacity++ , Tile (..)+ , tileDrawAttributes+ , tileFilterAttr+ , tileIn++ , Offset (..)+ , offsetDrawAttributes+ , offsetFilterAttr+ , offsetIn+ , offsetDX+ , offsetDY++ , MergeNode (..)+ , mergeNodeDrawAttributes+ , mergeNodeIn++ , Merge (..)+ , mergeDrawAttributes+ , mergeFilterAttributes+ , mergeChildren++ , ImageF (..)+ , imageFDrawAttributes+ , imageFFilterAttr+ , imageFHref+ , imageFAspectRatio++ , ComponentTransfer (..)+ , compTransferDrawAttributes+ , compTransferFilterAttr+ , compTransferChildren+ , compTransferIn++ , FuncA (..)+ , FuncType (..)+ , funcADrawAttributes+ , funcAType+ , funcATableValues+ , funcASlope+ , funcAIntercept+ , funcAAmplitude+ , funcAExponent+ , FuncR (..)+ , funcRDrawAttributes+ , funcRType+ , funcRTableValues+ , funcRSlope+ , funcRIntercept+ , funcRAmplitude+ , funcRExponent+ , FuncG (..)+ , funcGDrawAttributes+ , funcGType+ , funcGTableValues+ , funcGSlope+ , funcGIntercept+ , funcGAmplitude+ , funcGExponent+ , FuncB (..)+ , funcBDrawAttributes+ , funcBType+ , funcBTableValues+ , funcBSlope+ , funcBIntercept+ , funcBAmplitude+ , funcBExponent+ , ColorMatrixType(..) , colorMatrixDrawAttributes , colorMatrixFilterAttr
src/Graphics/SvgTree/Types/Hashable.hs view
@@ -63,6 +63,39 @@ deriving instance Hashable FilterElement +deriving instance Hashable Blend+deriving instance Hashable BlendMode++deriving instance Hashable ConvolveMatrix++deriving instance Hashable Morphology+deriving instance Hashable OperatorType+deriving instance Hashable NumberOptionalNumber++deriving instance Hashable SpecularLighting++deriving instance Hashable DropShadow++deriving instance Hashable DiffuseLighting++deriving instance Hashable Flood++deriving instance Hashable Tile++deriving instance Hashable Offset++deriving instance Hashable Merge+deriving instance Hashable MergeNode++deriving instance Hashable ImageF++deriving instance Hashable ComponentTransfer+deriving instance Hashable FuncType+deriving instance Hashable FuncA+deriving instance Hashable FuncR+deriving instance Hashable FuncG+deriving instance Hashable FuncB+ deriving instance Hashable ColorMatrix deriving instance Hashable FilterSource
src/Graphics/SvgTree/Types/Instances.hs view
@@ -73,6 +73,54 @@ instance HasDrawAttributes Composite where drawAttributes = compositeDrawAttributes +instance HasDrawAttributes Blend where+ drawAttributes = blendDrawAttributes++instance HasDrawAttributes ConvolveMatrix where+ drawAttributes = convolveMatrixDrawAttributes++instance HasDrawAttributes Morphology where+ drawAttributes = morphologyDrawAttributes++instance HasDrawAttributes SpecularLighting where+ drawAttributes = specLightingDrawAttributes++instance HasDrawAttributes DropShadow where+ drawAttributes = dropShadowDrawAttributes++instance HasDrawAttributes DiffuseLighting where+ drawAttributes = diffuseLightingDrawAttributes++instance HasDrawAttributes ComponentTransfer where+ drawAttributes = compTransferDrawAttributes++instance HasDrawAttributes FuncA where+ drawAttributes = funcADrawAttributes+instance HasDrawAttributes FuncR where+ drawAttributes = funcRDrawAttributes+instance HasDrawAttributes FuncG where+ drawAttributes = funcGDrawAttributes+instance HasDrawAttributes FuncB where+ drawAttributes = funcBDrawAttributes++instance HasDrawAttributes Flood where+ drawAttributes = floodDrawAttributes++instance HasDrawAttributes Tile where+ drawAttributes = tileDrawAttributes++instance HasDrawAttributes Offset where+ drawAttributes = offsetDrawAttributes++instance HasDrawAttributes Merge where+ drawAttributes = mergeDrawAttributes++instance HasDrawAttributes ImageF where+ drawAttributes = imageFDrawAttributes++instance HasDrawAttributes MergeNode where+ drawAttributes = mergeNodeDrawAttributes+ instance HasDrawAttributes ColorMatrix where drawAttributes = colorMatrixDrawAttributes @@ -88,9 +136,37 @@ instance HasDrawAttributes Text where drawAttributes = textRoot . spanDrawAttributes + instance HasFilterAttributes Filter where filterAttributes = filterSelfAttributes +instance HasFilterAttributes Blend where+ filterAttributes = blendFilterAttr++instance HasFilterAttributes ConvolveMatrix where+ filterAttributes = convolveMatrixFilterAttr++instance HasFilterAttributes Morphology where+ filterAttributes = morphologyFilterAttr++instance HasFilterAttributes SpecularLighting where+ filterAttributes = specLightingFilterAttr++instance HasFilterAttributes DropShadow where+ filterAttributes = dropShadowFilterAttr++instance HasFilterAttributes DiffuseLighting where+ filterAttributes = diffuseLightingFilterAttr++instance HasFilterAttributes Flood where+ filterAttributes = floodFilterAttr++instance HasFilterAttributes Tile where+ filterAttributes = tileFilterAttr++instance HasFilterAttributes Offset where+ filterAttributes = offsetFilterAttr+ instance HasFilterAttributes Composite where filterAttributes = compositeFilterAttr @@ -106,55 +182,66 @@ instance HasFilterAttributes DisplacementMap where filterAttributes = displacementMapFilterAttr +instance HasFilterAttributes Merge where+ filterAttributes = mergeFilterAttributes++instance HasFilterAttributes ImageF where+ filterAttributes = imageFFilterAttr++instance HasFilterAttributes ComponentTransfer where+ filterAttributes = compTransferFilterAttr+++ instance HasFilterAttributes FilterElement where filterAttributes = lens getter setter where getter fe = case fe of- FEBlend -> defaultSvg+ FEBlend b -> b ^. filterAttributes FEColorMatrix m -> m ^. filterAttributes- FEComponentTransfer -> defaultSvg+ FEComponentTransfer c -> c ^. filterAttributes FEComposite c -> c ^. filterAttributes- FEConvolveMatrix -> defaultSvg- FEDiffuseLighting -> defaultSvg+ FEConvolveMatrix c -> c ^. filterAttributes+ FEDiffuseLighting d -> d ^. filterAttributes FEDisplacementMap d -> d ^. filterAttributes- FEDropShadow -> defaultSvg- FEFlood -> defaultSvg- FEFuncA -> defaultSvg- FEFuncB -> defaultSvg- FEFuncG -> defaultSvg- FEFuncR -> defaultSvg+ FEDropShadow d -> d ^. filterAttributes+ FEFlood f -> f ^. filterAttributes+ FEFuncA _ -> defaultSvg --FuncA has no filter attributes+ FEFuncR _ -> defaultSvg --FuncR has no filter attributes+ FEFuncG _ -> defaultSvg --FuncG has no filter attributes+ FEFuncB _ -> defaultSvg --FuncB has no filter attributes FEGaussianBlur g -> g ^. filterAttributes- FEImage -> defaultSvg- FEMerge -> defaultSvg- FEMergeNode -> defaultSvg- FEMorphology -> defaultSvg- FEOffset -> defaultSvg- FESpecularLighting -> defaultSvg- FETile -> defaultSvg+ FEImage i -> i ^. filterAttributes+ FEMergeNode _ -> defaultSvg --MergeNode has no filterAttributes!+ FEMerge m -> m ^. filterAttributes+ FEMorphology m -> m ^. filterAttributes+ FEOffset o -> o ^. filterAttributes+ FESpecularLighting s -> s ^. filterAttributes+ FETile t -> t ^. filterAttributes FETurbulence t -> t ^. filterAttributes FENone -> defaultSvg setter fe attr = case fe of- FEBlend -> fe+ FEBlend b -> FEBlend $ b & filterAttributes .~ attr FEColorMatrix m -> FEColorMatrix $ m & filterAttributes .~ attr- FEComponentTransfer -> fe+ FEComponentTransfer c -> FEComponentTransfer $ c & filterAttributes .~ attr FEComposite c -> FEComposite $ c & filterAttributes .~ attr- FEConvolveMatrix -> fe- FEDiffuseLighting -> fe+ FEConvolveMatrix c -> FEConvolveMatrix $ c & filterAttributes .~ attr+ FEDiffuseLighting d -> FEDiffuseLighting $ d & filterAttributes .~ attr FEDisplacementMap d -> FEDisplacementMap $ d & filterAttributes .~ attr- FEDropShadow -> fe- FEFlood -> fe- FEFuncA -> fe- FEFuncB -> fe- FEFuncG -> fe- FEFuncR -> fe+ FEDropShadow d -> FEDropShadow $ d & filterAttributes .~ attr+ FEFlood f -> FEFlood $ f & filterAttributes .~ attr+ FEFuncA _ -> fe --FuncA has no filter atributes+ FEFuncR _ -> fe --FuncR has no filter atributes+ FEFuncG _ -> fe --FuncG has no filter atributes+ FEFuncB _ -> fe --FuncB has no filter atributes FEGaussianBlur g -> FEGaussianBlur $ g & filterAttributes .~ attr- FEImage -> fe- FEMerge -> fe- FEMergeNode -> fe- FEMorphology -> fe- FEOffset -> fe- FESpecularLighting -> fe- FETile -> fe+ FEImage i -> FEImage $ i & filterAttributes .~ attr+ FEMerge m -> FEMerge $ m & filterAttributes .~ attr+ FEMergeNode _ -> fe --MergeNode has no filterAttributes!+ FEMorphology m -> FEMorphology $ m & filterAttributes .~ attr+ FEOffset o -> FEOffset $ o & filterAttributes .~ attr+ FESpecularLighting s -> FESpecularLighting $ s & filterAttributes .~ attr+ FETile t -> FETile $ t & filterAttributes .~ attr FETurbulence t -> FETurbulence $ t & filterAttributes .~ attr FENone -> fe
src/Graphics/SvgTree/Types/Internal.hs view
@@ -62,6 +62,138 @@ FilterAttributes (..), HasFilterAttributes (..), FilterSource (..),++ Blend (..),+ BlendMode (..),+ blendDrawAttributes,+ blendFilterAttr,+ blendIn,+ blendIn2,+ blendMode,++ ConvolveMatrix (..),+ convolveMatrixDrawAttributes,+ convolveMatrixFilterAttr,+ convolveMatrixIn,+ convolveMatrixOrder,+ convolveMatrixKernelMatrix,+ convolveMatrixDivisor,+ convolveMatrixBias,+ convolveMatrixTargetX,+ convolveMatrixTargetY,+ convolveMatrixEdgeMode,+ convolveMatrixKernelUnitLength,+ convolveMatrixPreserveAlpha,++ Morphology (..),+ OperatorType (..),+ NumberOptionalNumber (..),+ morphologyDrawAttributes,+ morphologyFilterAttr,+ morphologyIn,+ morphologyOperator,+ morphologyRadius,++ SpecularLighting (..),+ specLightingDrawAttributes,+ specLightingFilterAttr,+ specLightingIn,+ specLightingSurfaceScale,+ specLightingSpecularConst,+ specLightingSpecularExp,+ specLightingKernelUnitLength,++ DropShadow (..),+ dropShadowDrawAttributes,+ dropShadowFilterAttr,+ dropShadowDx,+ dropShadowDy,+ dropShadowStdDeviation,++ DiffuseLighting,+ diffuseLightingDrawAttributes,+ diffuseLightingFilterAttr,+ diffuseLightingIn,+ diffuseLightingSurfaceScale,+ diffuseLightingDiffuseConst,+ diffuseLightingKernelUnitLength,++ Tile (..),+ tileDrawAttributes,+ tileFilterAttr,+ tileIn,++ Flood (..),+ floodDrawAttributes,+ floodFilterAttr,+ floodColor,+ floodOpacity,++ Offset (..),+ offsetDrawAttributes,+ offsetFilterAttr,+ offsetIn,+ offsetDX,+ offsetDY,++ Merge (..),+ mergeDrawAttributes,+ mergeFilterAttributes,+ mergeChildren,++ MergeNode (..),+ mergeNodeDrawAttributes,+ mergeNodeIn,++ ImageF (..),+ imageFDrawAttributes,+ imageFFilterAttr,+ imageFHref,+ imageFAspectRatio,++ ComponentTransfer (..),+ compTransferDrawAttributes,+ compTransferFilterAttr,+ compTransferChildren,+ compTransferIn,++ FuncA (..),+ FuncType (..),+ funcADrawAttributes,+ funcAType,+ funcATableValues,+ funcASlope,+ funcAIntercept,+ funcAAmplitude,+ funcAExponent,++ FuncR (..),+ funcRDrawAttributes,+ funcRType,+ funcRTableValues,+ funcRSlope,+ funcRIntercept,+ funcRAmplitude,+ funcRExponent,++ FuncG (..),+ funcGDrawAttributes,+ funcGType,+ funcGTableValues,+ funcGSlope,+ funcGIntercept,+ funcGAmplitude,+ funcGExponent,++ FuncB (..),+ funcBDrawAttributes,+ funcBType,+ funcBTableValues,+ funcBSlope,+ funcBIntercept,+ funcBAmplitude,+ funcBExponent,+ ColorMatrixType (..), colorMatrixDrawAttributes, colorMatrixFilterAttr,@@ -1104,34 +1236,182 @@ defaultSvg = NoNode data FilterElement- = FEBlend- | FEColorMatrix ColorMatrix- | FEComponentTransfer -- Need- | FEComposite Composite- | FEConvolveMatrix- | FEDiffuseLighting- | FEDisplacementMap DisplacementMap- | FEDropShadow- | FEFlood- | FEFuncA -- Need- | FEFuncB- | FEFuncG- | FEFuncR- | FEGaussianBlur GaussianBlur- | FEImage- | FEMerge- | FEMergeNode- | FEMorphology- | FEOffset- | FESpecularLighting- | FETile- | FETurbulence Turbulence+ = FEBlend Blend -- SVG Basic --DONE+ | FEColorMatrix ColorMatrix -- SVG Basic --DONE+ | FEComponentTransfer ComponentTransfer -- Need -- SVG Basic --DONE --Parser not working+ | FEComposite Composite -- SVG Basic --DONE+ | FEConvolveMatrix ConvolveMatrix --DONE -- No parser+ | FEDiffuseLighting DiffuseLighting --DONE -- No parser+ | FEDisplacementMap DisplacementMap --DONE+ | FEDropShadow DropShadow --DONE -- No parser+ | FEFlood Flood -- SVG Basic --DONE+ | FEFuncA FuncA -- Need -- SVG Basic --DONE+ | FEFuncB FuncB -- SVG Basic --DONE+ | FEFuncG FuncG -- SVG Basic --DONE+ | FEFuncR FuncR -- SVG Basic --DONE+ | FEGaussianBlur GaussianBlur -- SVG Basic --DONE+ | FEImage ImageF -- SVG Basic --DONE --Parser not working+ | FEMerge Merge -- SVG Basic --DONE+ | FEMergeNode MergeNode -- SVG Basic --DONE+ | FEMorphology Morphology --DONE -- No parser+ | FEOffset Offset -- SVG Basic --DONE+ | FESpecularLighting SpecularLighting --DONE -- No parser+ | FETile Tile -- SVG Basic --DONE+ | FETurbulence Turbulence --DONE | FENone deriving (Eq, Show, Generic) instance WithDefaultSvg FilterElement where defaultSvg = FENone +data SpecularLighting = SpecularLighting+ { _specLightingDrawAttributes :: DrawAttributes,+ _specLightingFilterAttr :: !FilterAttributes,+ _specLightingIn :: !(Last FilterSource),+ _specLightingSurfaceScale :: Double,+ _specLightingSpecularConst :: Double,+ _specLightingSpecularExp :: Double,+ _specLightingKernelUnitLength :: NumberOptionalNumber+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg SpecularLighting where+ defaultSvg =+ SpecularLighting+ { _specLightingDrawAttributes = defaultSvg,+ _specLightingFilterAttr = defaultSvg,+ _specLightingIn = Last Nothing,+ _specLightingSurfaceScale = 1,+ _specLightingSpecularConst = 1,+ _specLightingSpecularExp = 1,+ _specLightingKernelUnitLength = Num1 0+ }++data ConvolveMatrix = ConvolveMatrix+ { _convolveMatrixDrawAttributes :: DrawAttributes,+ _convolveMatrixFilterAttr :: !FilterAttributes,+ _convolveMatrixIn :: !(Last FilterSource),+ _convolveMatrixOrder :: NumberOptionalNumber,+ _convolveMatrixKernelMatrix :: [Double],+ _convolveMatrixDivisor :: Double,+ _convolveMatrixBias :: Double,+ _convolveMatrixTargetX :: Int,+ _convolveMatrixTargetY :: Int,+ _convolveMatrixEdgeMode :: EdgeMode,+ _convolveMatrixKernelUnitLength :: NumberOptionalNumber,+ _convolveMatrixPreserveAlpha :: Bool+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg ConvolveMatrix where+ defaultSvg =+ ConvolveMatrix+ { _convolveMatrixDrawAttributes = defaultSvg,+ _convolveMatrixFilterAttr = defaultSvg,+ _convolveMatrixIn = Last Nothing,+ _convolveMatrixOrder = Num1 3,+ _convolveMatrixKernelMatrix = [],+ _convolveMatrixDivisor = 1,+ _convolveMatrixBias = 0,+ _convolveMatrixTargetX = 1,+ _convolveMatrixTargetY = 1,+ _convolveMatrixEdgeMode = EdgeDuplicate,+ _convolveMatrixKernelUnitLength = Num1 0,+ _convolveMatrixPreserveAlpha = False+ }++data DiffuseLighting = DiffuseLighting+ { _diffuseLightingDrawAttributes :: DrawAttributes,+ _diffuseLightingFilterAttr :: !FilterAttributes,+ _diffuseLightingIn :: !(Last FilterSource),+ _diffuseLightingSurfaceScale :: Double,+ _diffuseLightingDiffuseConst :: Double,+ _diffuseLightingKernelUnitLength :: NumberOptionalNumber+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg DiffuseLighting where+ defaultSvg =+ DiffuseLighting+ { _diffuseLightingDrawAttributes = defaultSvg,+ _diffuseLightingFilterAttr = defaultSvg,+ _diffuseLightingIn = Last Nothing,+ _diffuseLightingSurfaceScale = 1,+ _diffuseLightingDiffuseConst = 1,+ _diffuseLightingKernelUnitLength = Num1 0+ }++data Morphology = Morphology+ { _morphologyDrawAttributes :: DrawAttributes,+ _morphologyFilterAttr :: !FilterAttributes,+ _morphologyIn :: !(Last FilterSource),+ _morphologyOperator :: OperatorType,+ _morphologyRadius :: NumberOptionalNumber+ }+ deriving (Eq, Show, Generic)+++instance WithDefaultSvg Morphology where+ defaultSvg =+ Morphology+ { _morphologyDrawAttributes = defaultSvg,+ _morphologyFilterAttr = defaultSvg,+ _morphologyIn = Last Nothing,+ _morphologyOperator = OperatorOver,+ _morphologyRadius = Num1 0+ }++data DropShadow = DropShadow+ { _dropShadowDrawAttributes :: DrawAttributes,+ _dropShadowFilterAttr :: !FilterAttributes,+ _dropShadowDx :: Double,+ _dropShadowDy :: Double,+ _dropShadowStdDeviation :: NumberOptionalNumber+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg DropShadow where+ defaultSvg =+ DropShadow+ { _dropShadowDrawAttributes = defaultSvg,+ _dropShadowFilterAttr = defaultSvg,+ _dropShadowDx = 2,+ _dropShadowDy = 2,+ _dropShadowStdDeviation = Num1 0+ }++data OperatorType+ = OperatorOver+ | OperatorIn+ | OperatorOut+ | OperatorAtop+ | OperatorXor+ | OperatorLighter+ | OperatorArithmetic+ deriving (Eq, Show, Generic)++data NumberOptionalNumber+ = Num1 Double+ | Num2 Double Double+ deriving (Eq, Show, Generic)++data ImageF = ImageF+ { _imageFDrawAttributes :: DrawAttributes,+ _imageFFilterAttr :: !FilterAttributes,+ _imageFHref :: !String,+ _imageFAspectRatio :: !PreserveAspectRatio+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg ImageF where+ defaultSvg =+ ImageF+ { _imageFDrawAttributes = defaultSvg,+ _imageFFilterAttr = defaultSvg,+ _imageFHref = "",+ _imageFAspectRatio = defaultSvg+ }+ data TransferFunctionType = TFIdentity | TFTable@@ -1183,6 +1463,250 @@ _displacementMapYChannelSelector = ChannelA } +data BlendMode+ = Normal+ | Multiply+ | Screen+ | Overlay+ | Darken+ | Lighten+ | ColorDodge+ | ColorBurn+ | HardLight+ | SoftLight+ | Difference+ | Exclusion+ | Hue+ | Saturation+ | Color+ | Luminosity+ deriving (Eq, Show, Generic)++data Blend = Blend+ { _blendDrawAttributes :: !DrawAttributes,+ _blendFilterAttr :: !FilterAttributes,+ _blendIn :: !(Last FilterSource),+ _blendIn2 :: !(Last FilterSource),+ _blendMode :: !BlendMode+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg Blend where+ defaultSvg =+ Blend+ { _blendDrawAttributes = defaultSvg,+ _blendFilterAttr = defaultSvg,+ _blendIn = Last Nothing,+ _blendIn2 = Last Nothing,+ _blendMode = Normal+ }++data Flood = Flood+ { _floodDrawAttributes :: !DrawAttributes,+ _floodFilterAttr :: !FilterAttributes,+ _floodColor :: !PixelRGBA8,+ _floodOpacity :: !(Maybe Double)+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg Flood where+ defaultSvg =+ Flood+ { _floodDrawAttributes = defaultSvg,+ _floodFilterAttr = defaultSvg,+ _floodColor = PixelRGBA8 0 0 0 255,+ _floodOpacity = Just 1.0+ }++data Offset = Offset+ { _offsetDrawAttributes :: !DrawAttributes,+ _offsetFilterAttr :: !FilterAttributes,+ _offsetIn :: !(Last FilterSource),+ _offsetDX :: !Number,+ _offsetDY :: !Number+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg Offset where+ defaultSvg =+ Offset+ { _offsetDrawAttributes = defaultSvg,+ _offsetFilterAttr = defaultSvg,+ _offsetIn = Last Nothing,+ _offsetDX = Num 0,+ _offsetDY = Num 0+ }++data Tile = Tile+ { _tileDrawAttributes :: !DrawAttributes,+ _tileFilterAttr :: !FilterAttributes,+ _tileIn :: !(Last FilterSource)+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg Tile where+ defaultSvg =+ Tile+ { _tileDrawAttributes = defaultSvg,+ _tileFilterAttr = defaultSvg,+ _tileIn = Last Nothing+ }++data Merge = Merge+ { _mergeDrawAttributes :: !DrawAttributes,+ _mergeFilterAttributes :: !FilterAttributes,+ _mergeChildren :: ![FilterElement]+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg Merge where+ defaultSvg =+ Merge+ { _mergeDrawAttributes = defaultSvg,+ _mergeFilterAttributes = defaultSvg,+ _mergeChildren = []+ }++data MergeNode = MergeNode+ { _mergeNodeDrawAttributes :: !DrawAttributes,+ --Does not have filter attributes!+ _mergeNodeIn :: !(Last FilterSource)+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg MergeNode where+ defaultSvg =+ MergeNode+ { _mergeNodeDrawAttributes = defaultSvg,+ _mergeNodeIn = Last Nothing+ }++data ComponentTransfer = ComponentTransfer+ { _compTransferDrawAttributes :: !DrawAttributes,+ _compTransferFilterAttr :: !FilterAttributes,+ _compTransferChildren :: ![FilterElement],+ _compTransferIn :: !(Last FilterSource)+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg ComponentTransfer where+ defaultSvg =+ ComponentTransfer+ { _compTransferDrawAttributes = defaultSvg,+ _compTransferFilterAttr = defaultSvg,+ _compTransferChildren = [],+ _compTransferIn = Last Nothing+ }++data FuncType+ = FIdentity+ | FTable+ | FDiscrete+ | FLinear+ | FGamma+ deriving (Eq, Show, Generic)++data FuncA = FuncA+ { _funcADrawAttributes :: !DrawAttributes,+ --Does not have filter attributes!+ _funcAType :: !FuncType,+ _funcATableValues :: ![Number],+ _funcASlope :: !Number,+ _funcAIntercept :: !Number,+ _funcAAmplitude :: !Number,+ _funcAExponent :: !Number+ --_funcAOffset :: _ -- This appears in the documentation, but no details are given.+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg FuncA where+ defaultSvg =+ FuncA+ { _funcADrawAttributes = defaultSvg,+ _funcAType = FIdentity, -- Standard does not define a default value.+ _funcATableValues = [],+ _funcASlope = Num 0,+ _funcAIntercept = Num 0,+ _funcAAmplitude = Num 1,+ _funcAExponent = Num 1+ }++data FuncR = FuncR+ { _funcRDrawAttributes :: !DrawAttributes,+ --Does not have filter attributes!+ _funcRType :: !FuncType,+ _funcRTableValues :: ![Number],+ _funcRSlope :: !Number,+ _funcRIntercept :: !Number,+ _funcRAmplitude :: !Number,+ _funcRExponent :: !Number+ --_funcAOffset :: _ -- This appears in the documentation, but no details are given.+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg FuncR where+ defaultSvg =+ FuncR+ { _funcRDrawAttributes = defaultSvg,+ _funcRType = FIdentity, -- Standard does not define a default value.+ _funcRTableValues = [],+ _funcRSlope = Num 0,+ _funcRIntercept = Num 0,+ _funcRAmplitude = Num 1,+ _funcRExponent = Num 1+ }++data FuncG = FuncG+ { _funcGDrawAttributes :: !DrawAttributes,+ --Does not have filter attributes!+ _funcGType :: !FuncType,+ _funcGTableValues :: ![Number],+ _funcGSlope :: !Number,+ _funcGIntercept :: !Number,+ _funcGAmplitude :: !Number,+ _funcGExponent :: !Number+ --_funcAOffset :: _ -- This appears in the documentation, but no details are given.+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg FuncG where+ defaultSvg =+ FuncG+ { _funcGDrawAttributes = defaultSvg,+ _funcGType = FIdentity, -- Standard does not define a default value.+ _funcGTableValues = [],+ _funcGSlope = Num 0,+ _funcGIntercept = Num 0,+ _funcGAmplitude = Num 1,+ _funcGExponent = Num 1+ }++data FuncB = FuncB+ { _funcBDrawAttributes :: !DrawAttributes,+ --Does not have filter attributes!+ _funcBType :: !FuncType,+ _funcBTableValues :: ![Number],+ _funcBSlope :: !Number,+ _funcBIntercept :: !Number,+ _funcBAmplitude :: !Number,+ _funcBExponent :: !Number+ --_funcAOffset :: _ -- This appears in the documentation, but no details are given.+ }+ deriving (Eq, Show, Generic)++instance WithDefaultSvg FuncB where+ defaultSvg =+ FuncB+ { _funcBDrawAttributes = defaultSvg,+ _funcBType = FIdentity, -- Standard does not define a default value.+ _funcBTableValues = [],+ _funcBSlope = Num 0,+ _funcBIntercept = Num 0,+ _funcBAmplitude = Num 1,+ _funcBExponent = Num 1+ }++ data ColorMatrixType = Matrix | Saturate@@ -1757,11 +2281,28 @@ makeLenses ''RadialGradient makeLenses ''Mask makeLenses ''ClipPath+makeLenses ''Blend+makeLenses ''Flood+makeLenses ''Tile+makeLenses ''Offset makeLenses ''ColorMatrix makeLenses ''Composite makeLenses ''GaussianBlur makeLenses ''Turbulence makeLenses ''DisplacementMap+makeLenses ''Merge+makeLenses ''MergeNode makeLenses ''Group+makeLenses ''ImageF+makeLenses ''ComponentTransfer+makeLenses ''FuncA+makeLenses ''FuncR+makeLenses ''FuncG+makeLenses ''FuncB+makeLenses ''Morphology+makeLenses ''SpecularLighting+makeLenses ''DropShadow+makeLenses ''DiffuseLighting+makeLenses ''ConvolveMatrix makeClassy ''FilterAttributes
src/Graphics/SvgTree/XmlParser.hs view
@@ -369,6 +369,61 @@ StrokePaint -> "StrokePaint" SourceRef s -> s +instance ParseableAttribute FuncType where+ aparse s = case s of+ "identity" -> Just FIdentity+ "table" -> Just FTable+ "discrete" -> Just FDiscrete+ "linear" -> Just FLinear+ "gamma" -> Just FGamma+ _ -> Nothing++ aserialize v = Just $ case v of+ FIdentity -> "identity"+ FTable -> "table"+ FDiscrete -> "discrete"+ FLinear -> "linear"+ FGamma -> "gamma"++instance ParseableAttribute BlendMode where+ aparse s = case s of+ "normal" -> Just Normal+ "multiply" -> Just Multiply+ "screen" -> Just Screen+ "overlay" -> Just Overlay+ "darken" -> Just Darken+ "lighten" -> Just Lighten+ "color-dodge" -> Just ColorDodge+ "color-burn" -> Just ColorBurn+ "hard-light" -> Just HardLight+ "soft-light" -> Just SoftLight+ "difference" -> Just Difference+ "exclusion" -> Just Exclusion+ "hue" -> Just Hue+ "saturation" -> Just Saturation+ "color" -> Just Color+ "luminosity" -> Just Luminosity+ _ -> Nothing++ aserialize v = Just $ case v of+ Normal -> "normal"+ Multiply -> "multiply"+ Screen -> "screen"+ Overlay -> "overlay"+ Darken -> "darken"+ Lighten -> "lighten"+ ColorDodge -> "color-dodge"+ ColorBurn -> "color-burn"+ HardLight -> "hard-light"+ SoftLight -> "soft-light"+ Difference -> "difference"+ Exclusion -> "exclusion"+ Hue -> "hue"+ Saturation -> "saturation"+ Color -> "color"+ Luminosity -> "luminosity"++ instance ParseableAttribute ColorMatrixType where aparse s = case s of "matrix" -> Just Matrix@@ -417,6 +472,44 @@ ChannelB -> "B" ChannelA -> "A" +instance ParseableAttribute OperatorType where+ aparse s = case s of+ "over" -> Just OperatorOver+ "in" -> Just OperatorIn+ "out" -> Just OperatorOut+ "atop" -> Just OperatorAtop+ "xor" -> Just OperatorXor+ "lighter" -> Just OperatorLighter+ "arithmetic" -> Just OperatorArithmetic+ _ -> Nothing++ aserialize v = Just $ case v of+ OperatorOver -> "over"+ OperatorIn -> "in"+ OperatorOut -> "out"+ OperatorAtop -> "atop"+ OperatorXor -> "xor"+ OperatorLighter -> "lighter"+ OperatorArithmetic -> "arithmetic"++instance ParseableAttribute NumberOptionalNumber where+ aparse s = case s of+ _ -> Nothing -- TODO++ aserialize v = Just $ case v of+ Num1 a -> show a+ Num2 a b -> show a ++ ", " ++ show b++instance ParseableAttribute Bool where+ aparse s = case s of+ "false" -> Just False+ "true" -> Just True+ _ -> Nothing++ aserialize v = Just $ case v of+ False -> "false"+ True -> "true"+ instance ParseableAttribute EdgeMode where aparse s = case s of "duplicate" -> Just EdgeDuplicate@@ -919,16 +1012,186 @@ xmlTagName _ = "FilterElement" serializeTreeNode fe = flip mergeAttributes <$> genericSerializeNode fe <*> case fe of- FEColorMatrix m -> serializeTreeNode m- FEComposite c -> serializeTreeNode c- FEGaussianBlur b -> serializeTreeNode b- FETurbulence t -> serializeTreeNode t- FEDisplacementMap d -> serializeTreeNode d- _ -> error $+ FEBlend b -> serializeTreeNode b+ FEColorMatrix m -> serializeTreeNode m+ FEComposite c -> serializeTreeNode c+ FEGaussianBlur b -> serializeTreeNode b+ FETurbulence t -> serializeTreeNode t+ FEDisplacementMap d -> serializeTreeNode d+ FETile t -> serializeTreeNode t+ FEFlood f -> serializeTreeNode f+ FEOffset o -> serializeTreeNode o+ FEMerge m -> serializeTreeNode m+ FEMergeNode n -> serializeTreeNode n+ FEImage i -> serializeTreeNode i+ FEComponentTransfer f -> serializeTreeNode f+ FEFuncA f -> serializeTreeNode f+ FEFuncR f -> serializeTreeNode f+ FEFuncG f -> serializeTreeNode f+ FEFuncB f -> serializeTreeNode f+ FESpecularLighting s -> serializeTreeNode s+ FEConvolveMatrix c -> serializeTreeNode c+ FEDiffuseLighting d -> serializeTreeNode d+ FEMorphology m -> serializeTreeNode m+ FEDropShadow d -> serializeTreeNode d+ _ -> error $ "Unsupported element: " ++ show fe ++ ". Please submit bug on github." attributes = [ "result" `parseIn` (filterAttributes . filterResult)] +instance XMLUpdatable ConvolveMatrix where+ xmlTagName _ = "feConvolveMatrix"+ serializeTreeNode = genericSerializeWithDrawAttr+ attributes =+ [ "in" `parseIn` convolveMatrixIn,+ "order" `parseIn` convolveMatrixOrder,+ "kernelMatrix" `parseIn` convolveMatrixKernelMatrix,+ "divisor" `parseIn` convolveMatrixDivisor,+ "bias" `parseIn` convolveMatrixBias,+ "targetX" `parseIn` convolveMatrixTargetX,+ "targetY" `parseIn` convolveMatrixTargetY,+ "edgeMode" `parseIn` convolveMatrixEdgeMode,+ "preserveAlpha" `parseIn` convolveMatrixPreserveAlpha ]++instance XMLUpdatable SpecularLighting where+ xmlTagName _ = "feSpecularLighting"+ serializeTreeNode = genericSerializeWithDrawAttr+ attributes =+ [ "in" `parseIn` specLightingIn,+ "surfaceScale" `parseIn` specLightingSurfaceScale,+ "specularConstant" `parseIn` specLightingSpecularConst,+ "specularExponent" `parseIn` specLightingSpecularExp,+ "kernelUnitLength" `parseIn` specLightingKernelUnitLength ]++instance XMLUpdatable DiffuseLighting where+ xmlTagName _ = "feDiffuseLighting"+ serializeTreeNode = genericSerializeWithDrawAttr+ attributes =+ [ "in" `parseIn` diffuseLightingIn,+ "surfaceScale" `parseIn` diffuseLightingSurfaceScale,+ "diffuseConstant" `parseIn` diffuseLightingDiffuseConst,+ "kernelUnitLength" `parseIn` diffuseLightingKernelUnitLength]++instance XMLUpdatable Morphology where+ xmlTagName _ = "feMorphology"+ serializeTreeNode = genericSerializeWithDrawAttr+ attributes =+ [ "in" `parseIn` morphologyIn,+ "operator" `parseIn` morphologyOperator,+ "radius" `parseIn` morphologyRadius ]++instance XMLUpdatable DropShadow where+ xmlTagName _ = "feDropShadow"+ serializeTreeNode = genericSerializeWithDrawAttr+ attributes =+ [ "dx" `parseIn` dropShadowDx,+ "dy" `parseIn` dropShadowDy,+ "stdDeviation" `parseIn` dropShadowStdDeviation ]++instance XMLUpdatable Blend where+ xmlTagName _ = "feBlend"+ serializeTreeNode = genericSerializeWithDrawAttr+ attributes =+ [ "in" `parseIn` blendIn+ , "in2" `parseIn` blendIn2+ , "mode" `parseIn` blendMode ]++instance XMLUpdatable FuncA where+ xmlTagName _ = "feFuncA"+ serializeTreeNode = genericSerializeWithDrawAttr+ attributes =+ [ "type" `parseIn` funcAType+ , "tableValues" `parseIn` funcATableValues+ , "slope" `parseIn` funcASlope+ , "intercept" `parseIn` funcAIntercept+ , "ampliture" `parseIn` funcAAmplitude+ , "exponent" `parseIn` funcAExponent ]++instance XMLUpdatable FuncR where+ xmlTagName _ = "feFuncR"+ serializeTreeNode = genericSerializeWithDrawAttr+ attributes =+ [ "type" `parseIn` funcRType+ , "tableValues" `parseIn` funcRTableValues+ , "slope" `parseIn` funcRSlope+ , "intercept" `parseIn` funcRIntercept+ , "ampliture" `parseIn` funcRAmplitude+ , "exponent" `parseIn` funcRExponent ]++instance XMLUpdatable FuncG where+ xmlTagName _ = "feFuncG"+ serializeTreeNode = genericSerializeWithDrawAttr+ attributes =+ [ "type" `parseIn` funcGType+ , "tableValues" `parseIn` funcGTableValues+ , "slope" `parseIn` funcGSlope+ , "intercept" `parseIn` funcGIntercept+ , "ampliture" `parseIn` funcGAmplitude+ , "exponent" `parseIn` funcGExponent ]++instance XMLUpdatable FuncB where+ xmlTagName _ = "feFuncB"+ serializeTreeNode = genericSerializeWithDrawAttr+ attributes =+ [ "type" `parseIn` funcBType+ , "tableValues" `parseIn` funcBTableValues+ , "slope" `parseIn` funcBSlope+ , "intercept" `parseIn` funcBIntercept+ , "ampliture" `parseIn` funcBAmplitude+ , "exponent" `parseIn` funcBExponent ]++instance XMLUpdatable Flood where+ xmlTagName _ = "feFlood"+ serializeTreeNode = genericSerializeWithDrawAttr+ attributes =+ [ "flood-color" `parseIn` floodColor+ , "flood-opacity" `parseIn` floodOpacity]++instance XMLUpdatable Tile where+ xmlTagName _ = "feTile"+ serializeTreeNode = genericSerializeWithDrawAttr+ attributes =+ [ "in" `parseIn` tileIn]++instance XMLUpdatable Offset where+ xmlTagName _ = "feOffset"+ serializeTreeNode = genericSerializeWithDrawAttr+ attributes =+ [ "in" `parseIn` offsetIn+ , "dx" `parseIn` offsetDX+ , "dy" `parseIn` offsetDY ]++instance XMLUpdatable Merge where+ xmlTagName _ = "feMerge"+ serializeTreeNode node =+ updateWithAccessor _mergeChildren node $+ genericSerializeWithDrawAttr node+ attributes = []++instance XMLUpdatable ComponentTransfer where+ xmlTagName _ = "feComponentTransfer"+ serializeTreeNode node =+ updateWithAccessor _compTransferChildren node $+ genericSerializeWithDrawAttr node+ attributes =+ [ "in" `parseIn` compTransferIn ]+++instance XMLUpdatable MergeNode where+ xmlTagName _ = "feMergeNode"+ serializeTreeNode = genericSerializeWithDrawAttr+ attributes =+ [ "in" `parseIn` mergeNodeIn ]++instance XMLUpdatable ImageF where+ xmlTagName _ = "feImage"+ serializeTreeNode = genericSerializeWithDrawAttr+ attributes =+ [ --parserSetter "href" imageFHref (Just . dropSharp) Just+ "href" `parseIn` imageFHref+ , "preserveAspectRatio" `parseIn` imageFAspectRatio+ ]+ instance XMLUpdatable ColorMatrix where xmlTagName _ = "feColorMatrix" serializeTreeNode = genericSerializeWithDrawAttr@@ -1205,8 +1468,51 @@ unRows e@(nodeName -> "meshrow") = [MeshGradientRow $ parseMeshGradientPatches e] unRows _ = [] +-- This is to guarantee there will be only "feMergeNode" elements inside any "feMerge" element.+unparseMergeNode :: X.Element -> FilterElement+unparseMergeNode e@(nodeName -> "feMergeNode") =+ FEMergeNode $ xmlUnparseWithDrawAttr e+unparseMergeNode _ = FENone++-- This is to guarantee there will be only "feFunc_" elements inside any "feComponentTransfer" element.+unparseFunc :: X.Element -> FilterElement+unparseFunc e = case nodeName e of+ "feFuncA" -> FEFuncA $ xmlUnparseWithDrawAttr e+ "feFuncR" -> FEFuncR $ xmlUnparseWithDrawAttr e+ "feFuncG" -> FEFuncG $ xmlUnparseWithDrawAttr e+ "feFuncB" -> FEFuncB $ xmlUnparseWithDrawAttr e+ _ -> FENone+ unparseFE :: X.Element -> FilterElement-unparseFE _ = FENone+unparseFE e@(nodeName -> "feMerge") =+ FEMerge $ xmlUnparseWithDrawAttr e & mergeChildren .~ map unparseMergeNode (elChildren e)+unparseFE e@(nodeName -> "feComponentTransfer") =+ FEComponentTransfer $ xmlUnparseWithDrawAttr e & compTransferChildren .~ map unparseFunc (elChildren e)+unparseFE e = case nodeName e of+ "feBlend" -> FEBlend parsed+ "feColorMatrix" -> FEColorMatrix parsed+ "feComposite" -> FEComposite parsed+ "feDisplacementMap" -> FEDisplacementMap parsed+ "feGaussianBlur" -> FEGaussianBlur parsed+ "feTurbulence" -> FETurbulence parsed+ "feTile" -> FETile parsed+ "feFlood" -> FEFlood parsed+ "feOffset" -> FEOffset parsed+ "feImage" -> FEImage parsed+ "feMergeNode" -> FEMergeNode parsed -- Potential bug: allow the "feMergeNode" element to appear outside a "feMerge" element.+ "feFuncA" -> FEFuncA parsed -- Potential bug: allow the "feFuncA" element to appear outside a "feComponentTransfer" element.+ "feFuncR" -> FEFuncR parsed -- Potential bug: allow the "feFuncR" element to appear outside a "feComponentTransfer" element.+ "feFuncG" -> FEFuncG parsed -- Potential bug: allow the "feFuncG" element to appear outside a "feComponentTransfer" element.+ "feFuncB" -> FEFuncB parsed -- Potential bug: allow the "feFuncB" element to appear outside a "feComponentTransfer" element.+ "feSpecularLighting" -> FESpecularLighting parsed+ "feConvolveMatrix" -> FEConvolveMatrix parsed+ "feDiffuseLighting" -> FEDiffuseLighting parsed+ "feMorphology" -> FEMorphology parsed+ "feDropShadow" -> FEDropShadow parsed+ _ -> FENone+ where+ parsed :: (WithDefaultSvg a, XMLUpdatable a, HasDrawAttributes a) => a+ parsed = xmlUnparseWithDrawAttr e unparse :: X.Element -> Tree unparse e@(nodeName -> "pattern") =
+ test/W3C.hs view
@@ -0,0 +1,85 @@+module Main (main) where++import Test.Tasty+import Test.Tasty.Ingredients.Rerun (defaultMainWithRerun)+import Test.Tasty.ExpectedFailure+import Test.Tasty.HUnit+import qualified Data.ByteString.Char8 as BS+import Graphics.SvgTree+import Graphics.SvgTree.Printer+import System.Process+import System.Directory+import System.FilePath+import Data.List+import System.Environment+import Data.Algorithm.Diff+import Data.Algorithm.DiffOutput+import Data.Char++main :: IO ()+main = do+ args <- getArgs+ case args of+ [path] -> do+ haveFile <- doesFileExist path+ if haveFile+ then do+ raw <- readFile path+ golden <- sanitizeSvg raw+ cycled <- sanitizeSvg (cycleSvg golden)+ if golden == cycled+ then putStrLn "Good"+ else do+ putStrLn "Mismatch!"+ let d = getGroupedDiff (lines golden) (lines cycled) :: [Diff [String]]+ ranges = diffToLineRanges d+ print (prettyDiffs ranges)+ else runTestSuite+ _ -> runTestSuite++runTestSuite :: IO ()+runTestSuite = do+ print =<< getCurrentDirectory+ good <- unitTestFolder "test/good"+ bad <- unitTestFolder "test/bad"+ defaultMainWithRerun $ testGroup "tests" [good, expectFail bad]++unitTestFolder :: FilePath -> IO TestTree+unitTestFolder path = do+ files <- sort <$> getDirectoryContents path+ return $ testGroup "animate"+ [ testSvg fullPath+ | file <- files+ , let fullPath = path </> file+ , takeExtension fullPath == ".svg"+ ]++testSvg :: FilePath -> TestTree+testSvg path = testCase (takeBaseName path) $ do+ raw <- readFile path+ golden <- prettyPrintSvg =<< sanitizeSvg raw+ cycled <- prettyPrintSvg (cycleSvg golden)+ assert (golden == cycled)++-- Sanitize SVG using rsvg-convert+sanitizeSvg :: String -> IO String+sanitizeSvg = readProcess "rsvg-convert" ["--format", "png"]++-- Ugly hack to ignore the differences between #FFF and #fff.+lowerHashValues :: String -> String+lowerHashValues ('#':more) = '#' : map toLower before ++ lowerHashValues after+ where+ (before, after) = splitAt 6 more+lowerHashValues (c:cs) = c:lowerHashValues cs+lowerHashValues [] = []++prettyPrintSvg :: String -> IO String+prettyPrintSvg = fmap lowerHashValues .+ readProcess "svgo" ["--input=-", "--output=-", "--pretty"+ , "--enable=sortAttrs,convertColors"+ , "--disable=cleanupIDs,prefixIds,convertTransform,mergePaths,collapseGroups" ]++-- Parse and print SVG with reanimate-svg library.+cycleSvg :: String -> String+cycleSvg = + maybe "Failed to parse" ppDocument . parseSvgFile "input" . BS.pack