Loading...
Logo
Processing Forum
Hi guys, 

I'm working on a project which requires me to draw in the control window, then save the images out using saveFrame. I'm unable to draw in the control window because i can't seem to get the control window to stop updating (setDrawBackground not working??)

here's the basic outline, thanks in advance

Copy code
  1. import controlP5.*;
  2. ControlWindow controlwindow;
  3. ControlWindowCanvas cc;
  4. ControlP5 controlP5;

  5. void setup() {
  6.   size(1024, 768);
  7.   controlP5 = new ControlP5(this);
  8.   controlwindow = controlP5.addControlWindow("controlP5window", 100, 100, 400, 768);
  9.   controlwindow.setBackground(color (0));
  10.   controlwindow.setDrawBackground(false); //this not working?

  11.   cc=new EmpCan();
  12.   cc.post();
  13.   controlwindow.addCanvas(cc);
  14. }

  15. void draw() {
  16. }

  17. class EmpCan extends ControlWindowCanvas {
  18.   public void setup(PApplet theApplet) {
  19.     theApplet.background(0);
  20.   }
  21.   public void draw(PApplet theApplet) {
  22.     
  23.     //create an image(from processing site)
  24.     PImage img = createImage(66, 66, RGB);
  25.     img.loadPixels();
  26.     for (int i = 0; i < img.pixels.length; i++) {
  27.       img.pixels[i] = color(0, 90, 102);
  28.     }
  29.     img.updatePixels();
  30.     //add it to draw
  31.     image(img, 17, 17);
  32.     //add it to canvas
  33.     theApplet.image(img,0,0);
  34.     theApplet.image(img, theApplet.width, theApplet.width);
  35.     
  36.     //draw ellipses in the Control Window(NOT WORKING)
  37.     if (theApplet.mousePressed) {
  38.       theApplet.fill(255, 100, 0);
  39.       theApplet.ellipse(theApplet.mouseX, theApplet.mouseY, 20, 20);
  40.     }
  41.     
  42.     //draw ellipses in the main window(WORKS)
  43.         if (theApplet.mousePressed) {
  44.       fill(255, 100, 0);
  45.       ellipse(theApplet.mouseX, theApplet.mouseY, 20, 20);
  46.       
  47.     }
  48.     
  49.     //this doesn't work either?
  50.   }
  51.   public void mouseReleased(PApplet theApplet) {
  52.     saveFrame();
  53.     println("yay");
  54.   }
  55. }