PShape seems to be broken, SVG graphics are distorted.

I tried this sample code from the processing website

PShape s;

void setup() {
  size(100, 100);
  // The file "bot.svg" must be in the data folder
  // of the current sketch to load successfully
  s = loadShape("bot.svg");
}

void draw() {
  shape(s, 10, 10, 80, 80);
}

The SVG renders a bit flattened, and I have no real control about where the shape will be displayed, cause the coordinates are messed up, what am I doing wrong?

Also, is it possible to alters the SVG's strokeWeight?, and if so how?

Answers

  • "flattened"? It isn't 3D... Perhaps you mean "squashed" or similar. Try to draw a square behind the shape and see if it is squashed too.

    "I have no real control about where the shape will be displayed, cause the coordinates are messed up"
    What do you mean by "messed up"? Here, a screen shot can help...

    Alter SVG's drawing parameter: see disableStyle().

  • edited November 2013

    It works now; this is the code;

    PShape moo;
    void setup() {
    size(400, 400);
    
    moo = loadShape("LENS-05.svg");
    
    
     }
     void draw() {
       background(255);
       moo.disableStyle();
       strokeWeight(1);
        shapeMode(CENTER);
       shape(moo,  mouseX, mouseY,300,300);
     }
    

    Also, the "Artboard" in Illustrator CS6 needs to be square, otherwise you get the said "Flattening", sorry for the late reply.

Sign In or Register to comment.