Modify simply svg shape for HTML output

Discuss SVG code, accessible via the XML Editor.
bmurphy88
Posts: 1
Joined: Tue May 19, 2015 3:59 am

Modify simply svg shape for HTML output

Postby bmurphy88 » Tue May 19, 2015 4:16 am

Hello,

I am having trouble with doing some simple modifications to a simple shape, saving it as a plain SVG and then rendering it in HTML within a <svg> tag.

First what works for me. If I start out with a new document and create a new shape and then immediately save that as a SVG I am able to open the .svg file, extract out the path data (the d attribute in the XML) and then render a simple <svg> element. The problem occurs when I make changes to the shape. If I just simply move the shape up or do a simple resize by dragging on the handles and then re-save, I get a transform attribute within the SVG XML file and the path hasn't changed. Ultimately what I need is for the path itself to update.

Now what I have tried is doing path --> simplify which does just that but something about the way the path is modified messes things up. The path seems unnaturally large and when I try to use it for HTML nothing shows up in the browser even if I increase the sizes of the view box.

Here's an example of the path differences with simply for clarity:

Freshly created shape

Code: Select all

<path d="m 64.082277,32.56329 a 31.803797,31.803797 0 1 1 -63.60759324,0 31.803797,31.803797 0 1 1 63.60759324,0 z" fill="#49b827" stroke="#FFFFFF" stroke-width="3.0"></path>


Modified shape by dragging on handle to make it larger and then running path --> simplify

Code: Select all

<path d="m 77.427561,1013.2008 c 0.368092,18.0749 -13.782896,34.9661 -31.62264,37.8243 -17.480446,3.4839 -36.321989,-7.0537 -42.560908,-23.735 -6.7103638,-16.2034 -0.4391592,-36.4061 14.275706,-45.95141 14.630444,-10.27562 36.258196,-8.19723 48.653597,4.69196 7.159099,7.09525 11.310176,17.08775 11.254245,27.17015 z" fill="#49b827" stroke="#FFFFFF" stroke-width="3.0"></path>


So now ultimately, my question. I need to make simple SVG's but my requirement is ONE path and any modifications I make such as moving or resizing needs to be reflected within that path.

Any guidance is very much appreciated :)

hulf2012
Posts: 716
Joined: Sat Nov 24, 2012 12:37 pm

Re: Modify simply svg shape for HTML output

Postby hulf2012 » Thu May 21, 2015 4:24 am

Go to Inkscape Preferences Shift + Ctrl + P. Go to Behavour >> Transformations >> and check Optimization box for the transformations.
Note the precise location of any node of a shape on Inkscape, is set to 8 decimal digits. You can also change it on Inkscape Preferences, but it could led to strange shape deformations.
Also, you can save as Plain SVG, or Optimized SVG, which it allows to save less code in the SVG.

Please, read the Guide that it's below in my firm . It's still vigent
If you have problems:
1.- Post a sample (or samples) of your file please.
2.- Please check here:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/index.html
3.- If you manage to solve your problem, please post here your solution.


Return to “SVG / XML Code”