svg relative to absolute conversion -


i have been developing application requires transformations in svg flattened, , co-ordinates absolute. conversion relative (or incremental) absolute causing me problem. original svg fragment sourced inkscape conversion of pdf svg (and yes it's pretty ordinay image!). inkscape has defined "paths" using relative co-ords. ran code convert absolute co-ordinates think trivial files render differently. appears start points fot paths moved.

i have been searching explanation why occurs. have looked @ converted file cannot see problem. starting point of paths match in each file match?

can offer reason why conversion not result in same result?

the source 2 files are: original relative:

<?xml version="1.0" encoding="utf-8" standalone="no"?>  <svg          xmlns:svg="http://www.w3.org/2000/svg"     xmlns="http://www.w3.org/2000/svg"     viewbox="2420 3960 70 40"     height="300"     width="700"     xml:space="preserve"     id="svg2436"     version="1.1">              <g                  id="g2446">           <path           id="path2616"           style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"           d="m 2440,3992.67 v 6 h -3 l -1,-1 h -2 l -1,-1 -1,-1 -1,-1 -1,-1 h -1 v -1 l -1,-2 -1,-1 v -3 l -1,-1 v -4 l 1,-2 v -1 l 1,-2 v -1 l 1,-1 1,-2 v -1 l 1,-1 1,13 v 3 l 1,1 1,2 h 1 l 1,1 1,1 h 2" /><path           id="path2618"           style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"           d="m 2453,3976.67 v 1 l -1,1 v 3 l -1,14 -1,-1 -1,-1 -1,-2 -1,-1 v -1 l -1,-1 v -10 l 1,-1 1,-1 v -1 l 1,-1 1,-1 1,-1 1,-1 1,-1" />           <path           id="path2620"           style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"           d="m 2477,3994.67 -1,1 -1,1 -1,1 h -2 l -1,1 h -1 l -2,1 h -10 l -1,-1 h -2 l -1,-1 -1,-1 -1,-1 h -1 l 1,-14 v 5 l 1,1 1,1 1,1 v 0 l 1,1 1,1 2,1 h 9 l 1,-1 h 1 l 2,-1 1,-1 1,-1 1,-1 v -2 l 1,-1 v -3" />           <path           id="path2622"           style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"           d="m 2482,3982.67 v 3 l -1,2 v 1 l -1,2 v 1 l -1,1 -1,1 -1,1 -1,-13 v -4 l -1,-1 -1,-1 -1,-1 -1,-1 h -1 l -1,-1 -1,-1 h -9 l -2,1 h -1 l -1,1 -1,1 -1,1 -1,1 v -6 h -7 l -1,1 h -2 v 0 l -2,1 h -2 l -1,1 -1,1 h -1 l -1,1 -1,1 -1,1 v 1 l -1,2 v 3 l -1,-13 1,-1 h 1 l 2,-1 1,-1 1,-1 h 2 v 0 l 1,-1 h 3 l 1,-1 h 6 l 2,-1 h 4 2 l 2,1 h 6 l 1,1 h 3 l 1,1 h 2 l 1,1 1,1 1,1 1,1 1,1 1,1 1,1 v 2 l 1,1 v 2 l 1,1 v 2" />        </g></svg>

same file converted absolute

<?xml version="1.0" encoding="utf-8" standalone="no"?>  <svg          xmlns:svg="http://www.w3.org/2000/svg"     xmlns="http://www.w3.org/2000/svg"     viewbox="2420 3960 70 40"     height="300"     width="700"     xml:space="preserve"     id="svg2436"     version="1.1">              <g id="g2446">           <path             id="path2616"             style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"             d="m2440,3992.67v3998.67h2437l2436,3997.67 h2434l2433,3996.67 2432,3995.67 2431,3994.67 h2430v3993.67l2429,3991.67 2428,3990.67 v3987.67l2427,3986.67 v3982.67l2428,3980.67 v3979.67l2429,3977.67 v3976.67l2430,3975.67 2431,3973.67 v3972.67l2432,3971.67 2433,3984.67 v3987.67l2434,3988.67 2435,3990.67 h2436l2437,3991.67 2438,3992.67 h2440" />            <path               id="path2618"               style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"               d="m2453,3976.67v3977.67l2452,3978.67 v3981.67l2451,3995.67 2450,3994.67 2449,3993.67 v3992.67l2448,3991.67 v3981.67l2449,3980.67 2450,3979.67 v3978.67l2451,3977.67 2452,3976.67 2453,3975.67 " />              <path                 id="path2620"                 style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"                 d="m2477,3994.67l2476,3995.67 2475,3996.67 h2473l2472,3997.67 h2471l2469,3998.67 h2459l2458,3997.67 h2456l2455,3996.67 2454,3995.67 h2453l2454,3981.67 v3986.67l2455,3987.67 2456,3988.67 v3988.67l2457,3989.67 2458,3990.67 h2467l2468,3989.67 h2469l2471,3988.67 2472,3987.67 2473,3986.67 v3984.67l2474,3983.67 v3980.67" />                <path                   id="path2622"                   style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none"                   d="m2482,3982.67v3985.67l2481,3987.67 v3988.67l2480,3990.67 v3991.67l2479,3992.67 2478,3993.67 2477,3994.67 v3990.67l2476,3989.67 2475,3988.67 2474,3987.67 h2473l2472,3986.67 2471,3985.67 h2462l2460,3986.67 h2459l2458,3987.67 2457,3988.67 2456,3989.67 v3983.67h2449l2448,3984.67 h2446v3984.67l2444,3985.67 h2442l2441,3986.67 2440,3987.67 h2439l2438,3988.67 2437,3989.67 v3990.67l2436,3992.67 v3995.67l2435,3982.67 2436,3981.67 h2437l2439,3980.67 2440,3979.67 h2442v3979.67l2443,3978.67 h2446l2447,3977.67 h2453l2455,3976.67 h2459l2461,3977.67 h2467l2468,3978.67 h2471l2472,3979.67 h2474l2475,3980.67 2476,3981.67 2477,3982.67 2478,3983.67 v3985.67l2479,3986.67 v3988.67l2480,3989.67 v3991.67" />        </g></svg>

you can inkscape use absolute path commands changing svg output preferences.

edit -> preferences -> input/output -> svg output -> path string format -> absolute

update

your paths not matching because not interpreting relative paths when converting.

if overlay original paths converted paths, can see going wrong. i'm including first path in example below.

<svg     xmlns:svg="http://www.w3.org/2000/svg"     xmlns="http://www.w3.org/2000/svg"     viewbox="2420 3960 70 40"     height="300"     width="700"     xml:space="preserve"     id="svg2436"     version="1.1">            <path       d="m 2440,3992.67 v 6 h -3 l -1,-1 h -2 l -1,-1 -1,-1 -1,-1 -1,-1 h -1 v -1 l -1,-2 -1,-1 v -3 l -1,-1 v -4 l 1,-2 v -1 l 1,-2 v -1 l 1,-1 1,-2 v -1 l 1,-1 1,13 v 3 l 1,1 1,2 h 1 l 1,1 1,1 h 2" />       <path        style="fill:red; fill-opacity:0.5"       d="m 2440,3992.67 v 3998.67 h 2437 l 2436,3997.67 h 2434 l 2433,3996.67 2432,3995.67 2431,3994.67 h2430v3993.67l2429,3991.67 2428,3990.67 v3987.67l2427,3986.67 v3982.67l2428,3980.67 v3979.67l2429,3977.67 v3976.67l2430,3975.67 2431,3973.67 v3972.67l2432,3971.67 2433,3984.67 v3987.67l2434,3988.67 2435,3990.67 h2436l2437,3991.67 2438,3992.67 h2440" />    </svg>

your first mistake @ sixth path command, l/l command multiple pairs of coordinates.

<svg viewbox="2420 3960 70 40" height="300" width="700">            <path       d="m 2440,3992.67          v 6          h -3          l -1,-1          h -2          l -1,-1            -1,-1            -1,-1            -1,-1          h -1          v -1 l -1,-2 -1,-1 v -3 l -1,-1 v -4 l 1,-2 v -1 l 1,-2 v -1 l 1,-1 1,-2 v -1 l 1,-1 1,13 v 3 l 1,1 1,2 h 1 l 1,1 1,1 h 2" />       <path        style="fill:red; fill-opacity:0.5"       d="m 2440,3992.67          v 3998.67          h 2437          l 2436,3997.67          h 2434          l 2433, 3996.67            2432, 3995.67            2431, 3994.67          h 2430" />    </svg>

the original relative path has 4 pairs of coordinates after l. converted version has three.

time debugging pass think. :)


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -