Launch Create draw() setup() Run Extras |
A Processing project is an applet that inherits (extends) the PApplet class. The class extends (inherit from) the PApplet class that is defined in the processing.core package. The PApplet class has done a lot of the work of animation for us. It will connecting to the graphic features already available on your computer and provide an infinite loop that repeatedly draws the contents of the applet. All we need to do is learn the processing commands and how to draw figures, text, and other to the applet window. Sounds easy and it is ... at least for simple animations. Let's get started.
To change from a standard Java application to PApplet we need to add the processing.core package to our project.
S:\processing-2.2.1\amd64_rhel7\core\library
We must now tell Eclipse that this core.jar file should be included in the build path. The build path is the list of folders that contain existing byte code needed to compile our project. The standard JRE package is already in our build path and it's easy to add core.jar.
Right-click the core.jar
file name in your package explorer view, and find the Build menu, select Add to build path from the Build menu. See figure below.
Voila. Now, we're ready make our class a Processing applet. At this point, your workspace should like this (or very similar):
MovingRectangle.java
file for editing. public class MovingRectangle extends PApplet {
// will put our methods here
}
This should cause Eclipse to complain. The errors are because class PApplet is not in the standard java.lang package.
import processing.core.*;
public class MovingRectangle extends PApplet {
// will put our methods here
}
As long as there are no red compiler errors, you know that your processing library has been installed correctly. There is not much code, but let's "run" it any way to see what happens.
You should find that the Applet Viewer window has popped up.Not much going on yet, but there it is.
4. When you're done running an applet, click the red close button [X]
to end the applet and close the window that was created for it.
Launch Create draw() setup() Run Extras
2015 Deb Deppeler