Skip to content

'scale' attribute causes feDisplacementMap attribute exception #15

Description

@bashirley

I love this gem; I end up pulling it out of the toolbox for something about every six months.

Problem
Following the example at https://stackoverflow.com/questions/30229943/hand-drawing-crayon-style-for-svg-path, I tried to create a brush-stroke filter like:

filter(:id=>'strokeFilter') do
	feTurbulence(:baseFrequency=>"0.2", :numOctaves=>"3", :type=>"fractalNoise")
	feDisplacementMap(:xChannelSelector=>"R", :in=>"SourceGraphic", :'scale'=>"8")
end

and got:
"svg_image.rb:169:in `validate_attribute': feDisplacementMap does not support attribute transform"

It looks like validate_attributes(attributes) sees the 'scale' attribute and tries to translate it to a 'transform' attribute internally, but 'scale' is actually a valid attribute on feDisplacementMap.

Possible Solution
I modified validate_attributes like:

  def validate_attributes(attributes , tag )
    clean_attributes = {}
    transforms = {}
    styles = {}

    attributes.each do |attribute, value|
      if Rasem::SVG_TRANSFORM.include?(attribute) && !Rasem::SVG_STRUCTURE[@tag.to_sym][:attributes].include?(attribute.to_sym)
        transforms[attribute] = value
        ...

(adding the tag parameter and the && !Rasem::SVG_STRUCTURE...) and it seems to work fine now. I haven't tested anything else, though.

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions