Inkscape.org
Beginners' Questions Interactive objects and setAttribte
  1. #1
    juankar juankar @juankar

    Hi

    I'm trying to learn about interactive objects, and I see that setAttribute doesn't work at all. I can use setAttribute ("fill-opacity", "0.4") for example, or setAttribute ("display", "none")... but I cannot use setAttribute ("fill", "red"), or setAttribute ("stroke-width", "2") and others SVG attributes. 
    But style does work fine. So, for example, if I want to change fill color I have to use style.fill 

    Am I doing some mistake? 

    Indeed It looks like setAttribute and SVG objects doens work  fine, I think.
     

  2. #2
    juankar juankar @juankar

    Auto-answer

    Afte examining this "problem" I've found that Inkscape saves svg with attributes as CSS styles, but If it's saved as optimized SVG then attributes are saved as pairs attributes=value.

    Then, in optimized SVG, setAttribute works like a charm!.

    I think Inkscape is a very good product, but, in my opinion, it needs a more complete documentation.

    Bye.

  3. #3
    Xav Xav @Xav👹

    I wrote about using JS with SVG over several of my Full Circle articles, starting from #82:

    http://www.peppertop.com/blog/?p=1563

    Some of that content might be useful to you.

     

Inkscape Inkscape.org Inkscape Forum Beginners' Questions Interactive objects and setAttribte