|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object processing.core.PShape processing.candy.BaseObject processing.candy.SVG
public class SVG
Candy is a minimal SVG import library for Processing. Candy was written by Michael Chang, and later revised and expanded for use as a Processing core library by Ben Fry.
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. Because of this size, it is not made part of processing.core, as it's not a feature that will be used by the majority of our audience. 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.
This library was specifically tested under SVG files created with Adobe Illustrator. We can't guarantee that it will work for any SVGs created with other software. In the future we would like to improve compatibility with Open Source software such as Inkscape, however initial tests show its base implementation produces more complicated files, and this will require more time.
An SVG created under Illustrator must be created in one of two ways:
A minimal example program using Candy: (assuming a working moo.svg is in your data folder)
import processing.candy.*; import processing.xml.*; SVG moo; void setup() { size(400,400); moo = new SVG("moo.svg",this); } void draw() { moo.draw(); }Note that processing.xml needs to be imported as well. This may not be required when running code within the Processing environment, but when exported it may cause a NoClassDefError. This will be fixed in later releases of Processing (Bug 518).
August 2008 revisions by fry (Processing 0149)
Field Summary |
---|
Constructor Summary | |
---|---|
SVG(PApplet parent,
java.lang.String filename)
Initializes a new SVG Object with the given filename. |
|
SVG(XMLElement svg)
Initializes a new SVG Object with the given filename. |
Method Summary |
---|
Methods inherited from class processing.candy.BaseObject |
---|
drawImpl, getChild, ignoreStyles, ignoreStyles, print |
Methods inherited from class processing.core.PShape |
---|
addChild, applyMatrix, applyMatrix, draw, draw, draw, drawMode, 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 SVG(PApplet parent, java.lang.String filename)
public SVG(XMLElement svg)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |