Hi , multisketch example comes with processing utilities library, here is the code:
what do you mean to pass the PApplet instance to it?
Code:
import org.gicentre.processing.utils.multisketch.*;
// Simple example to show how two sketches can be created in separate windows.
// Version 1.2, 18th July, 2009.
// Author Jo Wood.
// ----------------------- Object variables -------------------------
float rotationAngle;
// ----------------------- Initialisation ---------------------------
/** Sets up this sketch and adds another sketch in a separate window.
*/
void setup()
{
size(300,300);
PFont font = createFont("Serif",32);
textFont(font, 32);
smooth();
textAlign(CENTER,CENTER);
fill(120,20,20);
rotationAngle = 0;
PopupWindow win = new PopupWindow(this,new AnotherSketch());
win.setVisible(true);
}
// ----------------------- Processing draw --------------------------
void init()
{
frame.removeNotify();
frame.setUndecorated(true);
frame.addNotify();
super.init();
}
/** Displays some text and animates its rotation.
*/
void draw()
{
background(255,200,200);
pushMatrix();
translate(width/2,height/2);
rotate(rotationAngle);
text("Hello world",0,0);
popMatrix();
rotationAngle += 0.01;
}
Code:// Simple embedded sketch that can be placed in its own window.
// Version 1.2, 18th July, 2009.
// Author Jo Wood.
public class AnotherSketch extends EmbeddedSketch
{
// ----------------------- Object variables -------------------------
float textScale;
// ----------------------- Initialisation ---------------------------
/** Initialises the sketch ready to display some animated text.
*/
void setup()
{
size(300,300);
PFont font = createFont("SansSerif",24);
textFont(font, 24);
smooth();
textAlign(CENTER,CENTER);
fill(20,120,20);
textScale = 0;
}
void init()
{
frame.removeNotify();
frame.setUndecorated(true);
frame.addNotify();
super.init();
}
// ----------------------- Processing draw --------------------------
/** Displays some text and animates a change in size.
*/
void draw()
{
super.draw(); // Should be the first line of draw().
background(200,255,200);
pushMatrix();
translate(width/2,height/2);
scale(0.1+sin(textScale),1);
text("Hello again",0,0);
popMatrix();
textScale += 0.02;
}
}