Last active
August 29, 2015 14:15
-
-
Save guidoschmidt/0934d009095c0d60353f to your computer and use it in GitHub Desktop.
Minimal ControlP5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import controlP5.*; | |
import javax.swing.JFrame; | |
PFrame f = null; | |
Applet s; | |
ControlP5 cp5; | |
void setup() | |
{ | |
size(800, 800, P2D); | |
if(f==null)f = new PFrame(); | |
cp5 = new ControlP5(this); | |
cp5.addSlider("slider") | |
.setRange(0, 200) | |
.setWidth(500) | |
.setHeight(30) | |
.setPosition(20, 20) | |
.setValue(100); | |
} | |
void draw() | |
{ | |
} | |
public void slider(float theColor) | |
{ | |
println("a slider event. setting background to "+theColor); | |
} | |
public class Applet extends PApplet { | |
public void setup() { | |
size(600, 900); | |
noLoop(); | |
} | |
public void draw() { | |
fill(0); | |
ellipse(400, 60, 20, 20); | |
} | |
/* | |
* TODO: something like on Close set f to null, this is important if you need to | |
* open more secondapplet when click on button, and none secondapplet is open. | |
*/ | |
} | |
public class PFrame extends JFrame { | |
public PFrame() { | |
setBounds(0, 0, 600, 340); | |
s = new Applet(); | |
add(s); | |
s.init(); | |
println("birh"); | |
show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment