So now when we call sketch.ellipse() from the Ball class, it draws to our sketch. This code uses the this keyword to pass a reference to the current instance into the Ball constructor. Import public class MySketch extends PApplet But behind the scenes, when you press the play button, the Processing editor is translating your Processing code into Java code, compiling it, and running it.įor example, we might write Processing code that looks like this:
So far, we’ve used Processing through the Processing editor, which lets us write Processing code that the editor then runs when you press the play button. This tutorial combines those ideas and shows you how to use Processing as a Java library. You’ve also learned how to use Java libraries, which allow you to use classes and functions written by other people in your Java code. Calling Processing Functions From Non-Sketch ClassesĪt this point you’ve probably used Processing through the Processing editor, which lets you write Processing code and automatically run it.Processing in Java Processing in Java tutorial java processing