reanimate / reanimate-svg

BSD 3-Clause "New" or "Revised" License
4 stars 8 forks source link

Parser won't parse filter attributes of the effects nodes. #8

Open joseedil opened 4 years ago

joseedil commented 4 years ago

Filter attributes (height, result, width, x, y) are not parsed for filter elements. Take for example the attached SVG in which the feFlood and feOffset have specific width and height parameters.

I unsuccessfully tried tweaking the XMLUpdatable instance for the FilterElement data type. The only way a could solve it was by extending the attributes element for each individual filter element XMLUpdatable instance like so

instance XMLUpdatable Flood where
  xmlTagName _ = "feFlood"
  serializeTreeNode = genericSerializeWithDrawAttr
  attributes =
    [ "width" `parseIn` (filterAttributes . filterWidth)
    , "height" `parseIn` (filterAttributes . filterHeight)
    , "x" `parseIn` (filterAttributes . filterX)
    , "y" `parseIn` (filterAttributes . filterY)
    , "flood-color" `parseIn` floodColor
    , "flood-opacity" `parseIn` floodOpacity]

but I believe there must be a more generic way of solving it.

filters-tile-01-b.svg.txt filter-tile-01-v.dump.txt

lemmih commented 3 years ago

I think I partially fixed this. At least for the 'result' attribute.