import napplet.*;
NAppletManager nappletManager;
void setup() {
size(400, 400);
nappletManager = new NAppletManager(this); // Create the NAppletManager object.
nappletManager.createWindowedNApplet("MouseBox", 25, 25); // Add four NApplet objects to the manager.
nappletManager.createWindowedNApplet("MouseBlob", 25, 225); // After this, everything is on autopilot.
nappletManager.createWindowedNApplet("MouseBox", 225, 225);
nappletManager.createWindowedNApplet("MouseBlob", 225, 25);
}
void draw() {
background(50); // Don't need to do anything else. The NAppletManager handles the rest.
}
public class MouseBox extends NApplet {
// The contents of a NApplet object are exactly like the contents of a sketch.
int x, y;
void setup() {
size(150, 150);
stroke(255);
fill(100);
x = width/2;
y = height/2;
}
void draw() {
if (mousePressed) {
x = mouseX;
y = mouseY;
}
background(0);
translate(x, y);
rotate(frameCount*PI/180);
rect(-10, -10, 20, 20);
}
}
public class MouseBlob extends NApplet {
void setup() {
size(150, 150);
noStroke();
}
void draw() {
translate(width/2, height/2);
background(0);
fill(255*mouseX/width);
ellipse(0, 0, mouseY, mouseY);
}
}