Instead of working inside the processing IDE, you can use your prefered IDE and have a much better experience.
Create a new project in your prefered IDE. In this case I'm using IntelliJ IDEA CE.
Add the processing core to your project's library
- Go to
file->project structure - Go to thee library section and add click the
+button to add a new library. - On Mac OSX this is located at
/Applications/Processing.app/Contents/Java/Core.jar
- Go to
Create your main class that extends PApplet (add your import -
import processing.core.PApplet;)
importprocessing.core.PApplet;
publicclassAppextendsPApplet {
publicvoidsetup() {
frameRate(30);
}
publicvoidsettings() {
size(500, 500);
}
publicvoiddraw(){
// Global Draw Logicbackground(64);
rectMode(CENTER);
rect(mouseX, mouseY, 5, 5);
if (mousePressed) {
// ... example of handling mouse clicks
}
if (keyPressed) {
// example of handling keypressesif (key == 'a'){
// ...
} elseif (key == 'b'){
// ...
}
}
}
publicstaticvoidmain(String[] passedArgs) {
String[] appletArgs = newString[] { "App" };
PApplet.main(appletArgs);
}
}importprocessing.core.PApplet;
publicclassComponent {
privatePAppletp;
publicComponent(PAppletp, /* ...other params */) {
/* Component constructor */this.p = p;
// ... other constructor/initialization logic
}
publicvoidcalculate() {
/* Do all your calculations/setup here before drawing */
}
publicvoiddraw() {
// First, run the calculations/setupthis.calculate();
// To use processing methods just use the app instance.// e.g.// p.stroke(...);// p.fill(...);// p.rect(...);// etc.
}
}/* ... Main App Class */publicvoiddraw(){
// ... Other draw logic// Instantiate a new component and pass instance (this) as argument to have access to all processing methodsComponentcomponent = newComponent(this);
component.draw();
// ... Rest of main app draw logic
}
/* ... Rest of Main App Class */