About
napplet is a lightweight library that allows you to "embed" one Processing sketch inside another. This is potentially useful for a lot of things:
- displaying data in different ways within the same window without having one display muck up another
- creating a "control panel" in a portion of a sketch with buttons, etc. that control behavior elsewhere.
- importing an existing sketch into a new one (source code transfers easily).
To create and display NApplets, you simply create a NAppletManager object in the setup() method of the main sketch, and call NAppletManager.createNApplet() to create each sub-sketch and tell it where to draw in the main sketch. The NAppletManager then handles everything else "behind the scenes".
As an example, here's a demo that runs eight of the example sketches that come with Processing. I wrote this demo in the PDE. Here's the code for the main sketch:
- import napplet.*;
-
- PFont mainFont;
-
- void setup() {
- size(800, 400);
- mainFont = loadFont("ArialMT-18.vlw");
- textMode(SCREEN);
- textAlign(CENTER, TOP);
- NAppletManager nappletManager = new NAppletManager(this);
-
- nappletManager.createNApplet("Scrollbar", 0, 0);
- nappletManager.createNApplet("Pattern", 200, 0);
- nappletManager.createNApplet("Convolution", 400, 0);
- nappletManager.createNApplet("Animator", 600, 0);
- nappletManager.createNApplet("BouncyBubbles", 0, 200);
- nappletManager.createNApplet("FireCube", 200, 200);
- nappletManager.createNApplet("Tickle", 400, 200);
- nappletManager.createNApplet("UnlimitedSprites", 600, 200);
- }
-
- void draw() {
- background(50);
- }
Sketches contained in NApplets have access to all of the variables and methods of the parent sketch, so they can potentially be parts of a larger application.
Useful Links
Library download.
Source repository.
Wiki (includes rudimentary documentation, changelog, todo list.)
Old forum thread.