/* In this example we explore basic pendulum motion. Take a look at the Pendulum.pde file to explore the inner workings of our pendulum simulation. */ // we'll use one pendulum Pendulum p; void setup() { // setup the environment size(400, 400); background(0); colorMode(RGB, 255, 255, 255, 100); smooth(); // create a new pendulum with a fulcrum at the center of the // screen and an arm of length 150 p = new Pendulum(new Vector2D(width / 2, height / 2), 150.0f); } void draw() { // slowly fade out the screen fill(0, 5); rect(0, 0, width, height); // run our pendulum simulation p.simulate(); } void mousePressed() { // let the pendulum know the mouse was clicked p.clicked(mouseX, mouseY); } void mouseReleased() { // tell the pendulum the mouse has been released. p.stopDragging(); }