a port of the Processing Visualization Language
Name

loadShape()

Examples
example pic
PShape s;
s = loadShape("bot.svg");
smooth();
shape(s, 10, 10, 80, 80);
example pic
// 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.

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()

This reference is licensed under the CC BY-NC-SA 2.0 license:

Creative Commons License
Fork me on GitHub