feednplay_templates
To develop a Processing sketch to run in FeedNPlay, one of the following options is recommended:
Option 1
- Download this repository;
- Open the examples_other/simple example/;
- Build your content from it.
void settings() {
fnpSize(500, 500, P2D); // This line must the first one of settings()
smooth(8);
// Insert your settings code here
}
void setup() {
frameRate(60);
// Insert your setup code here
fnpEndSetup(); // This line must the last one of setup()
}
void draw() {
// Insert your draw code here
}
Recommendations
Loading data in Processing sketches properly
If your Processing sketch needs to load files or any data at startup, we recommend that you don't do it in the setup()
function as it may take a few seconds and thus trigger a Processing timeout error (RuntimeException: Waited 5000ms …). Instead, we recommend that you load all the required data in the second drawing frame (not the first). To do this, you can adapt your draw()
function based on the following code:
void draw() {
if (frameCount <= 2) {
if (frameCount == 2) {
// Insert your load code here
}
} else {
// Insert your draw code here
}
}