|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object processing.core.PShape processing.core.PShapeSVG
public class PShapeSVG
SVG stands for Scalable Vector Graphics, a portable graphics format. It is a vector format so it allows for infinite resolution and relatively small file sizes. Most modern media software can view SVG files, including Adobe products, Firefox, etc. Illustrator and Inkscape can edit SVG files.
We have no intention of turning this into a full-featured SVG library. The goal of this project is a basic shape importer that is small enough to be included with applets, meaning that its download size should be in the neighborhood of 25-30k. Starting with release 0149, this library has been incorporated into the core via the loadShape() command, because vector shape data is just as important as the image data from loadImage().
For more sophisticated import/export, consider the Batik library from the Apache Software Foundation. Future improvements to this library may focus on this properly supporting a specific subset of SVG, for instance the simpler SVG profiles known as SVG Tiny or Basic, although we still would not support the interactivity options.
A minimal example program using SVG: (assuming a working moo.svg is in your data folder)
PShape moo; void setup() { size(400, 400); moo = loadShape("moo.svg"); } void draw() { background(255); shape(moo, mouseX, mouseY); }This code is based on the Candy library written by Michael Chang, which was later revised and expanded for use as a Processing core library by Ben Fry. Thanks to Ricard Marxer Pinon for help with better Inkscape support in 0154.
Late October 2008 revisions from ricardmp, incorporated by fry (0154)
Field Summary |
---|
Fields inherited from class processing.core.PShape |
---|
BEZIER_VERTEX, BREAK, CURVE_VERTEX, GEOMETRY, GROUP, height, PATH, PRIMITIVE, VERTEX, width |
Constructor Summary | |
---|---|
PShapeSVG(PApplet parent,
java.lang.String filename)
Initializes a new SVG Object with the given filename. |
|
PShapeSVG(PShapeSVG parent,
XMLElement properties)
|
|
PShapeSVG(XMLElement svg)
Initializes a new SVG Object from the given XMLElement. |
Method Summary | |
---|---|
PShape |
getChild(java.lang.String name)
Get a particular element based on its SVG ID. |
void |
print()
Prints out the SVG document. |
Methods inherited from class processing.core.PShape |
---|
addChild, apply, applyMatrix, applyMatrix, applyMatrix, applyMatrix, disableStyle, draw, drawImpl, enableStyle, findChild, getChild, getChildCount, getHeight, getName, getWidth, isVisible, post, resetMatrix, rotate, rotate, rotateX, rotateY, rotateZ, scale, scale, scale, setName, setVisible, translate, translate |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PShapeSVG(PApplet parent, java.lang.String filename)
public PShapeSVG(XMLElement svg)
public PShapeSVG(PShapeSVG parent, XMLElement properties)
Method Detail |
---|
public PShape getChild(java.lang.String name)
// This code grabs "Layer 3" and the shapes beneath it. SVG layer3 = svg.getChild("Layer 3");
getChild
in class PShape
public void print()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |