Unable to draw a stroke-dasharray from a svg file

Hi,

I have a complex svg with several layers. I can load and draw it in Processing 3.3.2 without problem except for a dash array stroke that appears as a normal stroke instead. I created a simple sketch to replicate the problem:

PShape svg;

void setup() {
  size(500, 500);
  background(127);
  svg = loadShape("drawing.svg");
}

void draw() {
  shape(svg, 20, 20);
}

And this a code with only a dasharray stroke (saved as drawing.svg):

<?xml version="1.0" encoding="UTF-8"?>
<svg width="64.97mm" height=".57186mm" version="1.1" viewBox="0 0 64.969917 0.57185906" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
 <metadata>
  <rdf:RDF>
   <cc:Work rdf:about="">
    <dc:format>image/svg+xml</dc:format>
    <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
    <dc:title/>
   </cc:Work>
  </rdf:RDF>
 </metadata>
 <g transform="translate(-22.7 -64.637)">
  <g transform="matrix(.67278 0 0 -.67278 87.669 64.923)">
   <path d="m0 0h-96.57" fill="none" stroke="#fc6500" stroke-dasharray="1.971, 1.971" stroke-miterlimit="3.864" stroke-width=".85"/>
  </g>
 </g>
</svg>

Is the stroke-dasharray attribute from path not supported by Processing at loading svg files? I tested this file by opening it in Inkscape, Google Chrome and Adobe Illustrator and they all paint the dash array correctly.

Answers

  • I'm really surprised that no one is able to tell what is wrong here and other questions are quickly answered. Seems that I will have to move to another tool other than Processing in order to continue my project.

  • I have tried to run this, but i got:
    [Fatal Error] :2:96: The value of attribute "xmlns" associated with an element type "svg" must not contain the '<' character.

    cameyo

  • edited April 2017

    Seems that pasting the code and formatting as javascript in the forum added HTML elements. But without formatting it is even worse. How can I paste the original code without any changes by the forum interpreter?

  • edited April 2017

    We can paste code inside <pre></pre> tags as mentioned on the link below:
    https://forum.Processing.org/two/discussion/15473/readme-how-to-format-code-and-text

    However what's not said on that article is that < characters when followed by a non-space character needs to be replaced by &lt;. L-)

    Other problematic characters w/ same glitch are : & @.
    Replace them w/ &#58; & &#x40; respectively. :)>-

    There may be others though. But those 3 are the 1s I know about. 8-|

  • Answer ✓

    I have tried with another svg file (with stroke-dasharray) and it is... invisible :(

  • Answer ✓

    the processing svg parser doesn't handle everything that is possible to do with an SVG file (the svg spec is massive). nothing you can really do about it unfortunately.

  • Well thanks for your answers. So even if I achieve to make the same image with Processing code, It won't be possible to render it to a svg back again

Sign In or Register to comment.