im trying to import a svg file to the processing stage. when i set size(1024,670,P3D) its working.
but if i increase height ( >670 ) . the svg file disappears
Code:
import processing.core.*;
import processing.xml.*;
public class svgtest extends PApplet {
int svgWidth, svgHeight;
Shape3D[] shapes;
int num;
public void setup() {
size(1024, 728, P3D);
XMLElement xml = new XMLElement(this, "testdrawing.svg");
svgWidth = xml.getIntAttribute("width");
svgHeight = xml.getIntAttribute("height");
// create 3d SVG shapes
XMLElement[] kids = xml.getChild(0).getChildren();
num = kids.length;
System.out.println("no of children"+num);
shapes = new Shape3D[num];
for(int i=0; i<num; i++) {
String id = kids[i].getStringAttribute("id");
shapes[i] = new Shape3D(id, kids[i]);
}
colorMode(HSB, num);
noStroke();
}
public void draw() {
background(0);
// draw 3d shapes
for(int i=0; i<num; i++) {
Shape3D s = shapes[i];
int c;
pushMatrix();
c=color(i,128,255);
// draw shape with custom color
s.disableStyle();
fill(c);
shape(s, 0, 0);
popMatrix();
}
}
}
this is the Shape3D class
Code:
import processing.core.PGraphics;
import processing.core.PShapeSVG;
import processing.xml.XMLElement;
class Shape3D extends PShapeSVG {
String id;
float depth;
Shape3D(String _id, XMLElement xml) {
super(null, xml);
parsePath(); // create vertices
id = _id;
}
public void draw(PGraphics g) {
// draw bottom
quickDraw(g);
if(depth > 0) {
// draw top
g.pushMatrix();
g.translate(0, 0, depth);
quickDraw(g);
g.popMatrix();
// draw side faces
g.beginShape(QUAD_STRIP);
for(int i=0; i<vertexCount; i++) {
float[] v = vertices[i];
g.vertex(v[0], v[1], 0);
g.vertex(v[0], v[1], depth);
}
g.endShape();
}
}
// quick and dirty - no curves just straight lines
public void quickDraw(PGraphics g) {
g.beginShape();
for(int i=0; i<vertexCount; i++)
g.vertex(vertices[i][0], vertices[i][1]);
g.endShape();
}
}
actually this is a example which i found in some site. i tried to increase the screen resolution. but it didnt work.
any suggestions ?