HELP with PShape objects
in
Programming Questions
•
2 years ago
Hi there,
I'm rather new to Processing and I'm currently attempting to build a simple animation using SVG images. I have three objects at the moment that I've built at the moment which I'm using as my background. Each is its own SVG file and I've added all three to my processing sketch. Whenever I attempt to run the sketch I get the following error.
Here is my code, which is divided into four tabsException in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: 2at processing.core.PShapeSVG.<init>(PShapeSVG.java:187)at processing.core.PShapeSVG.<init>(PShapeSVG.java:168)at processing.core.PApplet.loadShape(PApplet.java:4153)at processing.core.PApplet.loadShape(PApplet.java:4114)at shapeTest$Tree.<init>(shapeTest.java:67)at shapeTest.setup(shapeTest.java:30)at processing.core.PApplet.handleDraw(PApplet.java:1608)at processing.core.PApplet.run(PApplet.java:1530)at java.lang.Thread.run(Thread.java:680)
shapeTest.pde
- //Initialize shapes
- Tree tree;
- Ground ground;
- Bushes bushes;
-
- void setup() {
- size(400,400);
- smooth();
- //create shapes
- tree = new Tree();
- ground = new Ground();
- bushes = new Bushes();
- }
- void draw() {
- background(255);
- ground.display();
- bushes.display();
- tree.display();
- }
- class Bushes {
- PShape bushes;
- Bushes() {
- bushes = loadShape("Bushes.svg");
- }
- void display() {
- shape(bushes,0,0,400,400);
- }
- }
Ground.pde
- class Ground {
- PShape ground;
- Ground() {
- ground = loadShape("Ground.svg");
- }
- void display() {
- shape(ground,0,0,400,400);
- }
- }
Tree.pde
- class Tree {
- PShape tree;
- Tree() {
- tree = loadShape("Tree.svg");
- }
- void display() {
- shape(tree,0,0,400,400);
- }
- }
1