Search processing.org:

Reference for Processing version 1.0+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

Name | ### loadShape()
Examples |
    PShape s;
    s = loadShape("bot.svg");
    smooth();
    shape(s, 10, 10, 80, 80);
    // Loading a shape when using setup() and draw()

    PShape s;

    void setup() {
      s = loadShape("bot.svg");
      smooth();
      noLoop();
    }

    void draw() {
      shape(s, 10, 10, 80, 80);
    }
Description | Loads vector shapes into a variable of type PShape. Currently, only SVG files may be loaded. To load correctly, the file must be located in the data directory of the current sketch. In most cases, loadShape() should be used inside setup() because loading shapes inside draw() will reduce the speed of a sketch. The filename parameter can also be a URL to a file found online. For security reasons, a Processing sketch found online can only download files from the same server from which it came. Getting around this restriction requires a signed applet. If a shape is not loaded successfully, the null value is returned and an error message will be printed to the console. The error message does not halt the program, however the null value may cause a NullPointerException if your code does not check whether the value returned from loadShape() is null.
Syntax |
    loadShape(filename)
Parameters |
filename | String: name of file to load
Returns | PShape or null
Usage | Web & Application
Related | PShape shape() shapeMode()

Updated on November 22, 2008 08:39:25pm PST