rasem icon indicating copy to clipboard operation
rasem copied to clipboard

'scale' attribute causes feDisplacementMap attribute exception

Open bashirley opened this issue 7 years ago • 0 comments

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!

bashirley avatar Dec 12 '17 17:12 bashirley