Hi,
Around four or five years ago I came up with this code which I now slightly edited. I would like to export a PDF on keypressed but can’t seem to make it work… everytime the pdf exports it’s empty. Any ideas or help would be appreciated.
import fisica.*;
//create a new world
FWorld world;
FBox obstacles[];
void setup() {
size(1400, 820);
//initialize Fisica
Fisica.init(this);
obstacles = new FBox[15];
//world constructor
world = new FWorld();
//create edges (walls) on the perimeter of our world
//world.setEdges();
//world.remove(world.left);
//world.remove(world.right);
//world.remove(world.top);
//world.setGravity(0,200);
for (int i=0; i<obstacles.length; i++) {
FBox b;
b = new FBox(random(10,300), 10);
b.setPosition(random(width, width*2), random(height));
b.setStroke(random(255),random(255),random(255));
b.setStatic(true);
b.setFill(random(255),random(255),random(255));
b.setRotation(random(360));
b.setRotatable(true);
obstacles[i] = b;
world.add(b);
}
}
void draw() {
//background(255);
for (int i=0; i<obstacles.length; i++) {
FBox o = obstacles[i];
o.setPosition(o.getX() - 2, o.getY());
if (o.getX() < -o.getWidth() / 2) {
o.setPosition(width+o.getWidth() / 2, random(height));
}
float rotSpeed = radians(1);
o.setRotation(o.getRotation() + rotSpeed);
}
//these 2 lines are used to advance the animation,
//just leave them here at the end of the draw()
world.draw();
world.step();
}