<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with registermethod() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=registermethod%28%29</link>
      <pubDate>Sun, 08 Aug 2021 19:37:52 +0000</pubDate>
         <description>Tagged with registermethod() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedregistermethod%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Do things on a thread separate of draw</title>
      <link>https://forum.processing.org/two/discussion/25848/do-things-on-a-thread-separate-of-draw</link>
      <pubDate>Sat, 06 Jan 2018 16:21:50 +0000</pubDate>
      <dc:creator>theliquu69</dc:creator>
      <guid isPermaLink="false">25848@/two/discussions</guid>
      <description><![CDATA[<p>I have a method <code>update()</code>, and I want to run it separately of draw. Basically <code>update()</code> has to be faster than <code>draw()</code>, because otherwise the program is slow. How do I do that?</p>
]]></description>
   </item>
   <item>
      <title>event when I change size</title>
      <link>https://forum.processing.org/two/discussion/27804/event-when-i-change-size</link>
      <pubDate>Fri, 20 Apr 2018 06:58:14 +0000</pubDate>
      <dc:creator>matthieu</dc:creator>
      <guid isPermaLink="false">27804@/two/discussions</guid>
      <description><![CDATA[<p>Hi friends,</p>

<p>I'm using <code>surface.setResizable(true);</code> to can adapt the size of my window, it runs perfectly.
I'm asking if there is an way to catch this event when I change the size with my mouse.
I need to change the size of my PGraphics inside my sketch.
Is it possible ?</p>
]]></description>
   </item>
   <item>
      <title>Java script error Processing/Kinect + Isadora</title>
      <link>https://forum.processing.org/two/discussion/26921/java-script-error-processing-kinect-isadora</link>
      <pubDate>Mon, 19 Mar 2018 11:12:18 +0000</pubDate>
      <dc:creator>luciedance</dc:creator>
      <guid isPermaLink="false">26921@/two/discussions</guid>
      <description><![CDATA[<p>Hi I have experienced Java script error when working with Isadora. Any help would be appreciated. I have logged it with TroikaTronix forum too.
<img src="" alt="" />
Thank you.<img src="https://forum.processing.org/two/uploads/imageupload/998/DFWPP4GY8GOJ.png" alt="Screen Shot 2018-03-19 at 10.55.45" title="Screen Shot 2018-03-19 at 10.55.45" />
<img src="https://forum.processing.org/two/uploads/imageupload/844/MQIO5G4NHI57.png" alt="Screen Shot 2018-03-19 at 10.56.18" title="Screen Shot 2018-03-19 at 10.56.18" />
<img src="https://forum.processing.org/two/uploads/imageupload/878/J1XXGXQGHLHM.png" alt="Screen Shot 2018-03-19 at 10.56.43" title="Screen Shot 2018-03-19 at 10.56.43" /></p>
]]></description>
   </item>
   <item>
      <title>How does G4P draw buttons without anything being in the draw method?</title>
      <link>https://forum.processing.org/two/discussion/26478/how-does-g4p-draw-buttons-without-anything-being-in-the-draw-method</link>
      <pubDate>Thu, 22 Feb 2018 11:18:13 +0000</pubDate>
      <dc:creator>jordanb92</dc:creator>
      <guid isPermaLink="false">26478@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,</p>

<p>Question is as in title. I'm curious about how buttons are displayed but can't see anything in the code that hints why nothing is needed in the draw method.</p>

<p>Thanks,
Jordan</p>
]]></description>
   </item>
   <item>
      <title>registerMethod() of keyEvent not compiling in custom library...</title>
      <link>https://forum.processing.org/two/discussion/23890/registermethod-of-keyevent-not-compiling-in-custom-library</link>
      <pubDate>Tue, 22 Aug 2017 12:17:07 +0000</pubDate>
      <dc:creator>FFD8</dc:creator>
      <guid isPermaLink="false">23890@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to add some useful keyboard functions to my XYscope library and hitting a strange problem within Eclipse to use a <code>registerMethod()</code> and keyEvent.</p>

<p>In the initialization of the library class, I'm calling the <code>registerMethod()</code> which works:
<code>p.registerMethod("keyEvent", this);</code></p>

<p>but I can only compile successfully if I create a public function of keyEvent without any parameters inside:</p>

<p><code>public void keyEvent(){ 
    p.println("test"); 
}</code></p>

<p>however when trying to run a sketch using the library in Processing, I get this error:
"There is no public keyEvent() method in the class xyscope.XYscope"</p>

<p>If I try to include the KeyEvent parameter like I've read about, the library won't compile:</p>

<p><code>public void keyEvent(KeyEvent evt){
    p.println("test");
}</code></p>

<p>The error I get while trying to compile is such:</p>

<p><code>102: error: cannot find symbol
    [javac]     public void keyEvent(KeyEvent evt){
    [javac]                          ^
    [javac]   symbol:   class KeyEvent
    [javac]   location: class XYscope</code></p>

<p>Any ideas out there what I might be doing wrong?</p>
]]></description>
   </item>
   <item>
      <title>Capturing keyEvent in own class: registerMethod()</title>
      <link>https://forum.processing.org/two/discussion/25477/capturing-keyevent-in-own-class-registermethod</link>
      <pubDate>Sat, 09 Dec 2017 18:20:52 +0000</pubDate>
      <dc:creator>kfrajer</dc:creator>
      <guid isPermaLink="false">25477@/two/discussions</guid>
      <description><![CDATA[<p>I was looking at the way to create my own that manages key events internally. So, it is required to intercept key events. This is my reference post: <a href="https://forum.processing.org/two/discussion/comment/104394/#Comment_104394" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/comment/104394/#Comment_104394</a> and the link to the PApplet's source code for reference <a rel="nofollow" href="https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java#L2903">PApplet.handleEvent()</a>: 
I am using almost the same code as from the PApplet. I see redundancy. My question is, is this the proper way to do this?</p>

<p>Kf</p>

<pre><code>import processing.core.*;
import processing.event.*;

TestClass aux;

void setup() {
  size(640, 480);
  fill(150);
  aux=new TestClass(this);
}

void draw() {
  background(0);
  if (frameCount%90==0) { 
    println(aux); 
    fill(random(50, 200));
  }
}


public class TestClass {
  int mX, mY;
  PApplet p;

  TestClass(PApplet pa) {
    p=pa;
    registerMethod("draw", this);
    //registerMethod("keyPressed", this);
    registerMethod("keyEvent", this);
  }

  public void keyEvent(KeyEvent event) {
    print("KE now  --&gt; ");

    if (!keyRepeatEnabled &amp;&amp; event.isAutoRepeat()) return;

    keyEvent = event;
    char key2 = event.getKey();
    keyCode = event.getKeyCode();

    switch (event.getAction()) {
    case KeyEvent.PRESS:     
      this.keyPressed( key2);      
      break;
    case KeyEvent.RELEASE:      
      this.keyReleased( key2);
      break;
    case KeyEvent.TYPE:
      this.keyTyped( key2);
      break;
    }
  }

  public void keyPressed(char inkey) {
    println("KE pressed!"+inkey);
  }

  public void keyReleased(char inkey) {
    println("KE releasedd!"+inkey);
  }

  public void keyTyped(char inkey) {
    println("KE typed!"+inkey);
  }

  public void draw() {
    ellipse(width&gt;&gt;1, height&gt;&gt;1, width&gt;&gt;2, height&gt;&gt;2);
  }

  <a href="/two/profile/Override">@Override</a>
    String toString() {
    String ss="";
    ss+="Mouse pointer: \t" +mX+"\t"+mY+"\n";   
    return ss;
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to make a button with relative position using G4P</title>
      <link>https://forum.processing.org/two/discussion/25179/how-to-make-a-button-with-relative-position-using-g4p</link>
      <pubDate>Fri, 24 Nov 2017 12:52:58 +0000</pubDate>
      <dc:creator>erwrow</dc:creator>
      <guid isPermaLink="false">25179@/two/discussions</guid>
      <description><![CDATA[<p>As the title mentions, i need to change the position of a button when the size (width and height) changes. is this posible?</p>
]]></description>
   </item>
   <item>
      <title>SimpleOpenNI fails with Processing 3.0</title>
      <link>https://forum.processing.org/two/discussion/13463/simpleopenni-fails-with-processing-3-0</link>
      <pubDate>Tue, 10 Nov 2015 06:34:01 +0000</pubDate>
      <dc:creator>aferriss</dc:creator>
      <guid isPermaLink="false">13463@/two/discussions</guid>
      <description><![CDATA[<p>I'm getting a no such method error when trying to run simple open ni in processing 3.0a9. This happens when I call</p>

<p><code>context = new SimpleOpenNI(this);</code></p>

<p>I assume this is because PApplet has been jettisoned? Putting opengl as my renderer gave me a bit more verbose information. Not sure exactly where to file this issue, since the simpleopenni google code page is no longer active.</p>

<pre><code>java.lang.RuntimeException: java.lang.NoSuchMethodError: processing.core.PApplet.registerDispose(Ljava/lang/Object;)V
    at processing.opengl.PSurfaceJOGL$2.run(PSurfaceJOGL.java:312)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodError: processing.core.PApplet.registerDispose(Ljava/lang/Object;)V
    at SimpleOpenNI.SimpleOpenNI.initEnv(SimpleOpenNI.java:383)
    at SimpleOpenNI.SimpleOpenNI.&lt;init&gt;(SimpleOpenNI.java:255)
    at kinectExample.setup(kinectExample.java:25)
    at processing.core.PApplet.handleDraw(PApplet.java:1958)
    at processing.opengl.PSurfaceJOGL$DrawListener.display(PSurfaceJOGL.java:566)
    at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:691)
    at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:673)
    at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:442)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1277)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1131)
    at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:680)
    at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:77)
    at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:451)
    at com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to use the draw() function in multiple tabs</title>
      <link>https://forum.processing.org/two/discussion/23950/how-to-use-the-draw-function-in-multiple-tabs</link>
      <pubDate>Mon, 28 Aug 2017 14:59:49 +0000</pubDate>
      <dc:creator>Tallen121</dc:creator>
      <guid isPermaLink="false">23950@/two/discussions</guid>
      <description><![CDATA[<p>So I'm trying out using multiple tabs for the first time ever, and I'm not sure proper tab etiquette, but is there a way to make it so I can use functions like draw() in multiple tabs? It gives me the error "Duplicate method draw() in tab1".</p>
]]></description>
   </item>
   <item>
      <title>listen to mouseEvents? (registerMethod)</title>
      <link>https://forum.processing.org/two/discussion/23645/listen-to-mouseevents-registermethod</link>
      <pubDate>Mon, 31 Jul 2017 03:55:24 +0000</pubDate>
      <dc:creator>gperez</dc:creator>
      <guid isPermaLink="false">23645@/two/discussions</guid>
      <description><![CDATA[<p>Hi. I'm using <strong>p5</strong> with <strong>ES6</strong> modules.
Basically, I created a global var named <code>p5</code> to make lib accessible in my classes.
Now, I want to be able to <em>listen</em> to mouseEvents. And I'm aware that there's a <code>registerMethod</code> function that should work like this:</p>

<p><code>p5.registerMethod("mouseEvent", this);</code></p>

<p>However, it just doesn't work. I'm not receiving any acknowledge in my <code>mouseEvent</code> method.</p>

<p>I've read the documentation <a rel="nofollow" href="https://github.com/processing/processing/wiki/Library-Basics">here</a> and <a rel="nofollow" href="https://github.com/processing/p5.js/wiki/Libraries">here</a>, but I'm not quite understanding if this is registering a new <em>something</em> that will be emitted or if this is a listener (observer pattern). Because in p5 the doc says by example:</p>

<p><code>p5.prototype.registerMethod('remove', p5.prototype.doRemoveStuff);</code></p>

<p>...  and prototype is for creating a new method (<em>registerMethod</em> in this case) and not to use one. Am i wrong? 
Anyway, tried also this and neither worked:</p>

<p><code>p5.__proto__.registerMethod("mouseEvent", this);</code></p>

<p>So, I just want to listen to events from a custom class. What am I missing? Any clue?</p>

<p>My code is:</p>

<pre><code>import * as P5 from 'p5' // used to access library constants

export class ControlZone extends Panel {

    constructor(x, y, width, height) {
        super(x, y, width, height);     

        p5.registerMethod("mouseEvent", this);
    }

    mouseEvent(event) {

    const x = event.getX();
    const y = event.getY();

      console.log("mouse Event");

      switch (event.getAction()) {
        case P5.MouseEvent.PRESS:
          // do something for the mouse being pressed
        this.mousePressed();
          break;
        case P5.MouseEvent.RELEASE:
          // do something for mouse released
        this.mouseReleased();
          break;
        case P5.MouseEvent.CLICK:
          // do something for mouse clicked
          break;
        case P5.MouseEvent.DRAG:
          // do something for mouse dragged
        this.mouseDragged();
          break;
        case P5.MouseEvent.MOVE:
          // do something for mouse moved
          break;
      }

         mousePressed () {
       console.log("mousePressed Event");
     }

    mouseDragged () {
        console.log("mouseDragged Event");
     }

    mouseReleased () {
           console.log("mouseReleased Event");
    }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to automate screendump creation of folder of sketches?</title>
      <link>https://forum.processing.org/two/discussion/23132/how-to-automate-screendump-creation-of-folder-of-sketches</link>
      <pubDate>Mon, 19 Jun 2017 14:11:34 +0000</pubDate>
      <dc:creator>Stixan</dc:creator>
      <guid isPermaLink="false">23132@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I recently taught a course on Computational Graphic Design, and the students have all handed in their assignments. This leaves me with a folder and several subfolders packed with Processing sketches. To get a visual overview of their assignments, I would like to automate the process of 1) traversing the folder structure, 2) opening all encountered ".pde" files one at a time, 3) run the open sketch, and 4) save the canvas - either directly from within Processing or via any third party software. Being able to do so will save me a lot of time, but I haven't got the slightest clue about how to make this happen. Any input will be highly appreciated. Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Translate mouse coordinates</title>
      <link>https://forum.processing.org/two/discussion/22247/translate-mouse-coordinates</link>
      <pubDate>Thu, 27 Apr 2017 15:12:58 +0000</pubDate>
      <dc:creator>Alex_Pr</dc:creator>
      <guid isPermaLink="false">22247@/two/discussions</guid>
      <description><![CDATA[<p>Is there a way to translate mouse coordinates when the canvas is also translated? In objects where mouse coordinates are used for control, this translation is useful if the object was set at position x,y of a translated canvas.</p>
]]></description>
   </item>
   <item>
      <title>When does millis start?</title>
      <link>https://forum.processing.org/two/discussion/22272/when-does-millis-start</link>
      <pubDate>Fri, 28 Apr 2017 20:36:27 +0000</pubDate>
      <dc:creator>Sjors</dc:creator>
      <guid isPermaLink="false">22272@/two/discussions</guid>
      <description><![CDATA[<p>Real quick question, does millis start when you reach void draw or does it start at setup?</p>
]]></description>
   </item>
   <item>
      <title>Mouse with two scroll wheels</title>
      <link>https://forum.processing.org/two/discussion/22226/mouse-with-two-scroll-wheels</link>
      <pubDate>Wed, 26 Apr 2017 15:48:16 +0000</pubDate>
      <dc:creator>Alex_Pr</dc:creator>
      <guid isPermaLink="false">22226@/two/discussions</guid>
      <description><![CDATA[<p>I have a Logitech MX Master which has a vertical and horizontal scroll wheel. The following way of tracking wheel changes works only for the vertical wheel. Is there a way to do the same for the horizontal wheel?</p>

<pre><code>void mouseWheel(MouseEvent event) {
  float e = event.getCount();
}
</code></pre>

<p>Thanks in advance,
Alex</p>
]]></description>
   </item>
   <item>
      <title>creating a library</title>
      <link>https://forum.processing.org/two/discussion/21049/creating-a-library</link>
      <pubDate>Tue, 28 Feb 2017 09:40:46 +0000</pubDate>
      <dc:creator>secondsky</dc:creator>
      <guid isPermaLink="false">21049@/two/discussions</guid>
      <description><![CDATA[<p>Hi all, it is not very clear to me how to create a library.
I checked this: <a href="https://github.com/processing/processing/wiki/Library-Basics" target="_blank" rel="nofollow">https://github.com/processing/processing/wiki/Library-Basics</a>
But a step by step guide would be more useful if someone know some online example.
In particular, how do i pass from my source files to the .jar?
Thank you</p>
]]></description>
   </item>
   <item>
      <title>Launching code during setup() without typing code into setup() [something like eventlistener('setup</title>
      <link>https://forum.processing.org/two/discussion/20493/launching-code-during-setup-without-typing-code-into-setup-something-like-eventlistener-setup</link>
      <pubDate>Fri, 27 Jan 2017 09:31:52 +0000</pubDate>
      <dc:creator>ens</dc:creator>
      <guid isPermaLink="false">20493@/two/discussions</guid>
      <description><![CDATA[<p>Hello!</p>

<p>I am new here so first i want to introduce myself. I work as an art &amp; animation teacher in the Netherlands and i am medior practitioner with code. I know a lot about PHP/SQL, javascript and i had some projects with processing using the kinect.</p>

<p>My question: Is it possible to launch some code while the setup() is called, but without actualy typing that code in the setup(){} - for example: when setup() is triggered, can you use something like program.addeventlistener( onSetup,   do this );</p>

<p>In my sketchfolder (main) are 2 files: main.pde and myclass.pde.
In the main.pde we find the basic functions setup() and draw()</p>

<p>In the myclass.pde i have a class:</p>

<p>class myclass{ 
   //constructor.
   myclass(){
      println("myclass initialized...");
   }
}</p>

<p>Normaly, to activate/initiate the class, i have to go to main.pde setup()</p>

<p>myclass MC;
void setup(){
   myclass MC = new myclass();
}
.... this works fine...</p>

<p>But now i want to know if it is possible to initiate the class when setup() is triggered, but without adding the [new myclass()] within the setup() function...  something like this:</p>

<p>myclass MC;
myproject.addeventlistner(  "on setup",   myclass MC = new myclass()  );</p>

<p>class myclass{ 
   //constructor.
   myclass(){
      println("myclass initialized...");
   }
}</p>

<p>is this even possible??</p>

<p>I am working with processing 3.2.3</p>

<p>Thanks in advance.</p>

<p>Emiel</p>
]]></description>
   </item>
   <item>
      <title>Can Sketch Window be Resized?</title>
      <link>https://forum.processing.org/two/discussion/19876/can-sketch-window-be-resized</link>
      <pubDate>Wed, 21 Dec 2016 22:52:33 +0000</pubDate>
      <dc:creator>RichardDL</dc:creator>
      <guid isPermaLink="false">19876@/two/discussions</guid>
      <description><![CDATA[<p>All the Processing sketch windows I've made are fixed size.  Maximise and size options are greyed out. (Using Windows a the moment. Size() without P2D or P3D.)  Is it possible to make a resizable window?  Is there a resize event function? (I've looked at doc on Size and Environment, not seen anything there.)</p>
]]></description>
   </item>
   <item>
      <title>mousePressed not working - simple code</title>
      <link>https://forum.processing.org/two/discussion/19056/mousepressed-not-working-simple-code</link>
      <pubDate>Tue, 15 Nov 2016 16:11:51 +0000</pubDate>
      <dc:creator>tder133</dc:creator>
      <guid isPermaLink="false">19056@/two/discussions</guid>
      <description><![CDATA[<p>Hi! I'm new to both coding and the boards so please bear with me. I'm trying to make a simple code where circles, which are supposed to represent tear drops, fall and the person controlling the mouse cursor, which takes on the image of a bucket, clicks on the tears to make them disappear, to make the illusion of tears falling into the bucket.</p>

<p>I'm having trouble with the mousePressed command. I cannot seem to be able to make the falling circles disappear when clicked on. Does anyone have any suggestions to help get me on the right track?</p>

<p>Here is what I have:</p>

<p><code>Tear t1;
PImage mouseCursor;
int numDrops = 80;
Tear[] drops = new Tear[numDrops]; // This creates the array of tears - how many will be able to fall.
void setup() {
  size(1000,800);
  background(0);
  smooth();
  noStroke(); // This loops the array of tears.
  for (int i = 0; i &lt; drops.length; i++) {
drops[i] = new Tear(); // This creates the tears as objects.
    t1 = new Tear();
  }
  mouseCursor = loadImage("bucket.png"); // This loads the image of the bucket as the cursor.
}
void draw(){
  fill(0,80);
  rect(0,0,1000,800); // This loops the array of tears.
  for (int i = 0; i &lt; drops.length; i++) {
    drops[i].fall();
  }
  if(mouseX &lt; 1000) { // This command makes the cursor the bucket image at all times.
    cursor(mouseCursor, 0, 0);
  } else {
    cursor(HAND);
  }
}
class Tear { // This allows the tears to be able to fall randomly at random positions on the screen.
  float t = random(1000);
  float y = random(-height);
void fall() {
    y = y + 10;
    fill(0,139,211,255); // The tears themselves. :'(
    ellipse(t, y, 10, 10);
    if(y&gt;height){
   t = random(1000);
   y = random(-200);
   }
  }
  void mousePressed(){
   ;if (mouseX &gt;= t &amp;&amp; mouseX &lt;= t + width &amp;&amp; 
   mouseY &gt;= y &amp;&amp; mouseY &lt;= y+ height){
    fill(0);
  } else {
    fill(0,139,211,255);}}
  }</code></p>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>error with my execution (fisica NoSuchMethodError)</title>
      <link>https://forum.processing.org/two/discussion/14088/error-with-my-execution-fisica-nosuchmethoderror</link>
      <pubDate>Sun, 20 Dec 2015 19:33:34 +0000</pubDate>
      <dc:creator>asangajnr</dc:creator>
      <guid isPermaLink="false">14088@/two/discussions</guid>
      <description><![CDATA[<p>hi guys please i need help, i am actully workng a monoploy game development and i have everything set but I have this error message while I run the application:</p>

<pre><code>Using this database: C:\Users\-\Desktop\Processing\-\data\-.db
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: org.jbox2d.dynamics.World.&lt;init&gt;(Lorg/jbox2d/collision/AABB;Lorg/jbox2d/common/Vec2;Z)V
    at fisica.FWorld.&lt;init&gt;(Unknown Source)
    at fisica.FWorld.&lt;init&gt;(Unknown Source)
    at sheergrace.setup(sheergrace.java:203)
    at processing.core.PApplet.handleDraw(PApplet.java:2281)
    at processing.opengl.PJOGL$PGLListener.display(PJOGL.java:799)
    at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:590)
    at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:574)
    at javax.media.opengl.awt.GLCanvas$9.run(GLCanvas.java:1218)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1036)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:911)
    at javax.media.opengl.awt.GLCanvas$10.run(GLCanvas.java:1229)
    at javax.media.opengl.Threading.invoke(Threading.java:193)
    at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:492)
    at javax.media.opengl.awt.GLCanvas.paint(GLCanvas.java:546)
    at sun.awt.RepaintArea.paintComponent(Unknown Source)
    at sun.awt.RepaintArea.paint(Unknown Source)
    at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
Already called beginDraw()
Using this database: C:\Users\-\Desktop\Processing\-\data\-.db
TuioClient: failed to connect to port 3333
java.lang.NullPointerException
    at processing.mode.java.runner.Runner.findException(Runner.java:926)
    at processing.mode.java.runner.Runner.reportException(Runner.java:871)
    at processing.mode.java.runner.Runner.exceptionEvent(Runner.java:797)
    at processing.mode.java.runner.Runner$2.run(Runner.java:686)
</code></pre>
]]></description>
   </item>
   <item>
      <title>Run code on exit (follow-up)</title>
      <link>https://forum.processing.org/two/discussion/579/run-code-on-exit-follow-up</link>
      <pubDate>Tue, 22 Oct 2013 05:03:35 +0000</pubDate>
      <dc:creator>sableRaph</dc:creator>
      <guid isPermaLink="false">579@/two/discussions</guid>
      <description><![CDATA[<p>This is a follow-up of the thread: <a href="http://forum.processing.org/one/topic/run-code-on-exit.html" target="_blank" rel="nofollow">http://forum.processing.org/one/topic/run-code-on-exit.html</a></p>

<p>The recommended method for running some code when closing the sketch used to be registering a dispose handler. However, it looks like the registerDispose() method from PApplet is deprecated (see <a rel="nofollow" href="http://processing.org/reference/javadoc/core/processing/core/PApplet.html#unregisterDispose(java.lang.Object)">Javadoc</a>)</p>

<p>The following code still works but is there a recommended alternative to the registerDispose() method?</p>

<pre><code>public class DisposeHandler {

DisposeHandler(PApplet pa)
{
  pa.registerDispose(this);
}

public void dispose()
{      
  println("Closing sketch");
}

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Objects to receive events</title>
      <link>https://forum.processing.org/two/discussion/16004/objects-to-receive-events</link>
      <pubDate>Wed, 13 Apr 2016 16:01:00 +0000</pubDate>
      <dc:creator>RALifeCoach</dc:creator>
      <guid isPermaLink="false">16004@/two/discussions</guid>
      <description><![CDATA[<p>I would love to be able to create an object that would have access to the processing events, but only when the event takes place within the scope of the object. Let me put it as an example. I want to create an object (say a star). If I click on the star I want the star object to receive the mouseClick event. I would then have the option of allowing it to propagate to other objects also under the mouse icon. If have 100 stars the logic to figure out which star was clicked is a bit tedious.</p>
]]></description>
   </item>
   <item>
      <title>using serial library - code works in java, not in python</title>
      <link>https://forum.processing.org/two/discussion/15143/using-serial-library-code-works-in-java-not-in-python</link>
      <pubDate>Fri, 26 Feb 2016 16:36:24 +0000</pubDate>
      <dc:creator>AndyJudkis</dc:creator>
      <guid isPermaLink="false">15143@/two/discussions</guid>
      <description><![CDATA[<p>Hello,<br />
I am a high-school teacher, interested in using the Python mode of Processing to communicate with Arduino for one of my classes.  The first program below works fine in java mode, but the Python version below it doesn't work.  I don't get any exception, and the device is correct, but the Python version of serialEvent() is never called.  Any ideas or suggestions?<br />
thanks<br />
Andy  <br /></p>

<h1>Java version, works fine:</h1>

<p>import processing.serial.*;</p>

<p>Serial myPort;<br />
PImage img;<br />
float lightVal;</p>

<p>void setup() {<br />
&nbsp;&nbsp;size(300,300, P3D);<br />
&nbsp;&nbsp;img = loadImage("cat1.jpeg");<br />
&nbsp;&nbsp;String devs[] = Serial.list();<br />
&nbsp;&nbsp;println(devs[devs.length - 1]);<br />
&nbsp;&nbsp;myPort = new Serial(this, devs[devs.length - 1], 9600);<br />
&nbsp;&nbsp;myPort.bufferUntil(10);<br />
}</p>

<p>void draw() {<br />
&nbsp;&nbsp;background(255);<br />
&nbsp;&nbsp;stroke(0);<br />
&nbsp;&nbsp;fill(175);</p>

<p>&nbsp;&nbsp;translate(width/2, height/2);<br />
&nbsp;&nbsp;rotateY(lightVal);</p>

<p>&nbsp;&nbsp;imageMode(CENTER);<br />
&nbsp;&nbsp;image(img, 0,0);<br />
}</p>

<p>void serialEvent(Serial myPort)<br />
{<br />
&nbsp;&nbsp;String inString = myPort.readStringUntil('\n');<br />
&nbsp;&nbsp;lightVal = map(float(inString), 0, 150, 0, TWO_PI);<br />
&nbsp;&nbsp;println("LightVal=" + str(lightVal));<br />
}</p>

<hr />

<h1>Python version, serialEvent never called:</h1>

<p>add_library('serial')</p>

<p>lightVal = 0;<br />
LF = 10  #linefeed ascii</p>

<p>def setup():<br />
&nbsp;&nbsp;global img<br />
&nbsp;&nbsp;global myPort<br />
&nbsp;&nbsp;size(300,300, P3D)<br />
&nbsp;&nbsp;img = loadImage("cat1.jpeg")<br />
&nbsp;&nbsp;portList = Serial.list()<br />
&nbsp;&nbsp;portName = portList[len(portList) - 1]<br />
&nbsp;&nbsp;print(portName)<br />
&nbsp;&nbsp;myPort = Serial(this, portName, 9600)<br />
&nbsp;&nbsp;myPort.bufferUntil(10)</p>

<p>def draw():<br />
&nbsp;&nbsp;background(255)<br />
&nbsp;&nbsp;stroke(0)<br />
&nbsp;&nbsp;fill(175)</p>

<p>&nbsp;&nbsp;translate(width/2, height/2)<br />
&nbsp;&nbsp;rotateY(lightVal)</p>

<p>&nbsp;&nbsp;imageMode(CENTER)<br />
&nbsp;&nbsp;image(img, 0,0)</p>

<p>def serialEvent(evt):<br />
&nbsp;&nbsp;inString = evt.readStringUntil('\n')<br />
&nbsp;&nbsp;lightVal = map(float(inString), 0, 150, 0, TWO_PI)<br />
&nbsp;&nbsp;print("lightVal=", lightVal)</p>
]]></description>
   </item>
   <item>
      <title>Run code on exit on processing 3</title>
      <link>https://forum.processing.org/two/discussion/13593/run-code-on-exit-on-processing-3</link>
      <pubDate>Sat, 21 Nov 2015 21:00:14 +0000</pubDate>
      <dc:creator>cladelpino</dc:creator>
      <guid isPermaLink="false">13593@/two/discussions</guid>
      <description><![CDATA[<p>Hi all, is the solution proposed in <a rel="nofollow" href="https://forum.processing.org/two/discussion/579/run-code-on-exit-follow-up">this </a>thread still true for processing 3 ?</p>

<p>regards and thanks
Claudio</p>
]]></description>
   </item>
   <item>
      <title>How do i get the parent object ?!</title>
      <link>https://forum.processing.org/two/discussion/12688/how-do-i-get-the-parent-object</link>
      <pubDate>Fri, 25 Sep 2015 19:03:21 +0000</pubDate>
      <dc:creator>peterpeter23</dc:creator>
      <guid isPermaLink="false">12688@/two/discussions</guid>
      <description><![CDATA[<p>I am using Proclipsing in Eclipse and i have some trouble getting the correct parent for my class.</p>

<p>First i am drawing a rectangle (A) with the parent to PApplet .
The rectangle (A) should be the parent of the rectangle (B) but the second rectangle isn't showing with my code.
I am also not able to correctly register the "draw" method in my code.</p>

<pre><code>import processing.core.PApplet;


public class Test extends PApplet {

    public void settings() {
        fullScreen();
    }

    public void setup() {
        background(21);

        clRect rectA= new clRect(this);
        rectA.left = 50;
        rectA.top = 50;
        rectA.width = 500;
        rectA.height = 500;

        clRect rectB= new clRect(rectA);
        rectB.left = 20;
        rectB.top = 20;
        rectB.width = 100;
        rectB.height = 100;
    }

    public void draw() {
        background(21);
    }

    public static void main(String _args[]) {
        PApplet.main(new String[] { test.Test.class.getName() });
    }
}
</code></pre>

<p>I am extending the rectangle class from another class which is supposed to be a controller class for multiple different classes.</p>

<pre><code>import processing.core.PApplet;

public class clControl extends PApplet 
{
    public PApplet parent;  //The parent object referred to
    public float left; 
    public float top; 
    public float width;
    public float height; 

    public clControl(PApplet parent)
    {
        this.parent = parent;
    }
}
</code></pre>

<p>Finally this is the rectangle class which is causing problems for me.
The first rectangle is drawn with no problem at all.
The second rectangle is not able to register the "draw" method and drawing the rectangle is also a problem, it is not showing.</p>

<pre><code>import processing.core.PApplet;

public class clRect extends clControl
{
    public clRect(PApplet parent) 
    {
        super(parent);

        this.left = 0;
        this.top = 0;
        this.width = 100;
        this.height = 200;

        this.parent.registerMethod("draw", this);
    }

    public void draw()
    {
        this.parent.rect(this.left, this.top, this.width, this.height);
    }
}
</code></pre>

<p>How to get this running? :(</p>
]]></description>
   </item>
   <item>
      <title>Problem for create a class</title>
      <link>https://forum.processing.org/two/discussion/12468/problem-for-create-a-class</link>
      <pubDate>Thu, 10 Sep 2015 21:33:58 +0000</pubDate>
      <dc:creator>AnimalMystik</dc:creator>
      <guid isPermaLink="false">12468@/two/discussions</guid>
      <description><![CDATA[<p>Hi, 
sorry for the mess, this forum is new for me and I don't know well the usages. I already created a thread for this question but it wasn't clear and I 'accidentally' mark some answer as a good answer without being able to cancel.</p>

<p>so, here is my main problem for the moment, I'm trying to port this code as a class</p>

<p>In fact, the selectFolder use a callback function : 'fileSelected'. but when I try to do that class conversion, it seems that I can't reach the callback method inside the class : "fileSelected() could not be found".</p>

<p>That's a thing which loose me a bit, I tried <strong>this.</strong>fileSelected but no luck.</p>

<p>How can I do ?</p>

<p>Also I'm not sure if I can't interrupt the draw() function from that class for draw a menu, in fact I can't figure out the ideal way for make it. I can't find any exemple that use a class loading a menu. Maybe this is simply a wrong approach ?</p>

<p>My final goal is to process image sequences, loading them , execute a process and save them inside a new folder.</p>

<p>Maybe that processing isn't a good environment for what I'm trying to do ? 
sorry, here is the working code that I'm trying to port as a class.</p>

<pre><code>PImage    img;
PFont     f;

String[]  list_file;
String    seq_png_absolutepath;
int[]     possible_seq;

int       idx_png_seq_selected;

boolean   png_menu   = false;
boolean   png_render = false;

class png_file {
  String  name;
  int     check_sum;
  int     num;
  int     len_num;
  boolean zero_format;
  boolean part_of_seq;
}

class png_sequence {
  String  name;
  boolean zero_format;
  int     len_zerof;
  int     nbr_file;
  int     first_frame;
  int     last_frame;
}

// Array Object
png_file[]     list_png;
png_sequence[] png_final_array;


void setup() 
{
  size(400, 400); 
  if (frame != null) {
    frame.setResizable(true);
  }
  f = createFont("Consolas", 16, true);
  noLoop();
  selectFolder("Select a file to process:", "fileSelected");
}

void draw() 
{

  background(0);

  if (png_menu) {
    textFont(f);       
    fill(255);

    textAlign(LEFT);
    text("Choose a sequence : ", 5, 20 );
    text("-------------------", 5, 34 );
    //mouseY
    if (mouseY &gt;= 36  &amp;&amp; mouseY &lt;= 36 + 14 * png_final_array.length) {
      //beginDraw();
      fill(255, 0, 0);
      rect(0, 36 + (round(mouseY - 36) / 14) * 14, width, 14);
    }
    fill(255);
    for (int i = 0; i &lt; png_final_array.length; i++) {
      int size_seq = 1 + png_final_array[i].last_frame - png_final_array[i].first_frame;
      text(png_final_array[i].name + ", " + size_seq + " images", 5, 50 + i * 14);
    }
  }

  if (mousePressed &amp;&amp; png_menu) { 
    png_menu = false;
    png_render = true;
    noLoop();
    idx_png_seq_selected = (round(mouseY - 36) / 14);

    img = loadImage(png_seq_recreate_name(idx_png_seq_selected, 3));
    println(png_seq_recreate_name(idx_png_seq_selected, 3));

    frame.setSize(img.width, img.height);
    println("img.width = " + img.width);
    image(img, 0, 0);
  }
}


void fileSelected(File selection) 
{
  if (selection == null) {
    println("Window was closed or the user hit cancel.");
  } else {
    if (png_detect(selection)) {
      png_menu = true;
      loop();
    }
  }
}

String png_seq_recreate_name(int idx, int n_image) {
  //n_image is relativ, that means that it alwayz begin by zero. (n_image + first_frame)


  String a;
  String n;
  a = png_final_array[idx].name;
  n = Integer.toString(n_image + png_final_array[idx].first_frame);
  &lt;del&gt;&lt;/del&gt;
  if (png_final_array[idx].zero_format) {
    int zero_n = png_final_array[idx].len_zerof - n.length();
    for (int i = 0; i &lt;  zero_n; i++) {
      println("i = " + i);
      n = "0"+ n;
    }
  }
  a = seq_png_absolutepath + "\\" + a + n + ".png";
  String b = Character.toString((char)92);

  println(b);
  println(b);
  println(b);
  println(a);
  a = a.replace("\\", "/");
  return a;
}


boolean png_detect(File selection) 
{
  String num;
  char   a  ;
  String ext;
  int    asc_l;
  int    len; 
  int    chk_sum;   
  int    png_count = 0;

  list_file = selection.list();
  seq_png_absolutepath = selection.getAbsolutePath();
  if (list_file == null) {
    println("Folder does not exist or cannot be accessed.");
  } else {

    list_png = new png_file[list_file.length];

    for (int i = 0; i &lt; list_file.length; i++) {
      num = "";
      len = list_file[i].length();
      ext = list_file[i].substring(len - 4, len); 

      //match png 
      if (ext.equals(".png")) {
        png_count++;
        list_png[png_count - 1] = new png_file();


        //name and number
        for (int j = len - 5; j &gt; 0; j--) {
          a      = list_file[i].charAt(j);
          asc_l  = (int) a;
          if (asc_l &gt;= 48 &amp;&amp; asc_l &lt;= 57) {
            num = a + num;
          } else {
            list_png[png_count - 1].len_num = (len - 5) - j;
            list_png[png_count - 1].name    = list_file[i].substring(0, j + 1);
            break;
          }
        }


        if (num.length() &gt; 0) {
          list_png[png_count - 1].part_of_seq = true;
          list_png[png_count - 1].num         = Integer.parseInt(num);
          list_png[png_count - 1].len_num     = num.length();

          if (num.length() &gt; 1) {
            if (new String("0").equals(num.substring(0, 1))) {
              list_png[png_count - 1].zero_format = true;
            } else {
              list_png[png_count - 1].zero_format = false;
            }
          }
        } else {
          list_png[png_count - 1].part_of_seq = false;
        }  


        chk_sum = 0;
        for (int j = 0; j &lt; len - 4 - num.length (); j++) {
          a = list_file[i].charAt(j);
          chk_sum += (int) a * (j + 1);
        }

        list_png[png_count - 1].check_sum = chk_sum;
      }
    }
  }




  possible_seq = new int[100]; 


  if (png_count &gt; 0) {
    println("PNG files detected :" + png_count);
    boolean numbered_png = false;
    for (int i = 0; i &lt; png_count; i++) {
      if (list_png[i].part_of_seq) { 
        numbered_png = true; 
        break;
      }
    }

    if (!numbered_png) { 
      println("Error : No numbered files detected !");
      return false;
    } else {
      int chk_count = 1;


      for (int i = 0; i &lt; png_count; i++) {
        if (i == 0) { 

          for (int j = 0; j &lt; png_count; j++) { 
            if (list_png[j].part_of_seq) {
              possible_seq[chk_count - 1] = list_png[j].check_sum;
              break;
            }
          }
        } else {

          if (list_png[i].part_of_seq) {
            boolean already_exist = false;

            for (int j = 0; j &lt; possible_seq.length; j++) {
              if (possible_seq[j] == list_png[i].check_sum) {
                already_exist = true; 
                break;
              }
            }

            if (!already_exist) {
              chk_count++;
              possible_seq[chk_count - 1] = list_png[i].check_sum;
            }
          }
        }
      }


      png_final_array = new png_sequence[chk_count++];

      for (int i = 0; i &lt; 100; i++) {
        if (possible_seq[i] == 0) {
          break;
        } else {

          for (int j = 0; j &lt; png_count; j++) {

            if (possible_seq[i] == list_png[j].check_sum) {
              png_final_array[i]             = new png_sequence();
              png_final_array[i].name        = list_png[j].name;
              png_final_array[i].zero_format = false;
              png_final_array[i].len_zerof   = 0;

              for (int k = 0; k &lt; png_count; k++) {
                if (possible_seq[i] == list_png[k].check_sum  &amp;&amp; list_png[k].zero_format) {
                  png_final_array[i].len_zerof   =  list_png[k].len_num;
                  png_final_array[i].zero_format = true;
                  break;
                }
              }

              break;
            }
          }


          int min = 300000;
          int max = 0;

          for (int j = 0; j &lt; png_count; j++) {
            if (list_png[j].check_sum == possible_seq[i]) {
              if (list_png[j].num &lt; min) { 
                min = list_png[j].num;
              }
              if (list_png[j].num &gt; max) { 
                max = list_png[j].num;
              }
            }
          }

          png_final_array[i].first_frame = min;
          png_final_array[i].last_frame  = max;
        }
      }
    }
  } else {
    println("There isn't PNG files in this folder");
    return false;
  }

  for (int i = 0; i &lt; png_final_array.length; i++) {
    println("Seq "+ i + " : " + png_final_array[i].name + " Zf :" + png_final_array[i].zero_format + " len Zf " + png_final_array[i].len_zerof + ", first num : " + png_final_array[i].first_frame + ", last_frame : " + png_final_array[i].last_frame);
  }


  return true;
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>mousePressed();</title>
      <link>https://forum.processing.org/two/discussion/11892/mousepressed</link>
      <pubDate>Thu, 30 Jul 2015 01:01:40 +0000</pubDate>
      <dc:creator>lviensen</dc:creator>
      <guid isPermaLink="false">11892@/two/discussions</guid>
      <description><![CDATA[<p>Minha duvida é sobre o mousePressed(), gostaria de saber se posso usá-lo mais de uma vez, por exemplo, em duas telas com menus. Se alguém puder me ajudar, agradeço.</p>
]]></description>
   </item>
   <item>
      <title>How come a "pre-defined" function cant be put inside of a class?</title>
      <link>https://forum.processing.org/two/discussion/11747/how-come-a-pre-defined-function-cant-be-put-inside-of-a-class</link>
      <pubDate>Sat, 18 Jul 2015 00:06:34 +0000</pubDate>
      <dc:creator>Meowsterr</dc:creator>
      <guid isPermaLink="false">11747@/two/discussions</guid>
      <description><![CDATA[<p>I tried putting void mousePressed inside of a class and it wouldn't work, but then when I moved it outside of the class it worked.  How come it only worked when outside of the class?</p>
]]></description>
   </item>
   <item>
      <title>running code on exit; again</title>
      <link>https://forum.processing.org/two/discussion/11648/running-code-on-exit-again</link>
      <pubDate>Fri, 10 Jul 2015 22:45:24 +0000</pubDate>
      <dc:creator>ondsinet_</dc:creator>
      <guid isPermaLink="false">11648@/two/discussions</guid>
      <description><![CDATA[<p>After reading many posts on this and on the old processing forums I've tried to compare the ways of running code on exit; but I've found no difference between registering a dispose handler as it is often suggested or overriding the exit() function;</p>

<p>meaning that</p>

<pre><code>void exit() {
  println("closing");
    super.exit();
  }
</code></pre>

<p>will be called every time the program is closed(via program,clicking on the red X,task manager...)except when closing from the processing ide.
Actually by removing the call to super.exit() the code can be runned in background while looking close(SO vulnerability?).
So wich one is better?</p>
]]></description>
   </item>
   <item>
      <title>How to get mouseClicked() and others functional in a class?</title>
      <link>https://forum.processing.org/two/discussion/10414/how-to-get-mouseclicked-and-others-functional-in-a-class</link>
      <pubDate>Mon, 20 Apr 2015 11:27:46 +0000</pubDate>
      <dc:creator>Magnetic_Garden</dc:creator>
      <guid isPermaLink="false">10414@/two/discussions</guid>
      <description><![CDATA[<p>I searched the intertubes high and low to find an answer, but either the answers where incomplete, obscure or deprecated..
How does the syntax in the class looks like (because this seems to be a bit unusual(?).
and how do I get the handler(the state of the mouse) into the class?, it has something to do with register function, but I found no info about this keyword...</p>

<p>thx in advance</p>

<p>I am working the whole day already on this problem and still I cannot get any meaningful results, Its irritating...</p>
]]></description>
   </item>
   <item>
      <title>CV Problems</title>
      <link>https://forum.processing.org/two/discussion/10986/cv-problems</link>
      <pubDate>Mon, 25 May 2015 09:56:19 +0000</pubDate>
      <dc:creator>StruanDW</dc:creator>
      <guid isPermaLink="false">10986@/two/discussions</guid>
      <description><![CDATA[<p>Hi guys;</p>

<p>I'm pretty new to Processing, so these problems are probably really easily fixed, but hey-oh.</p>

<p>I'd really appreciate any insight you can offer!</p>

<p>I'm getting the error ArrayIndexOutOfBoundsException:0 when I try to run this code:</p>

<pre><code>import processing.video.*;

Capture cam;
PImage frame;
PImage destination;

void setup() {

  String[] cameras = Capture.list();

  if (cameras.length == 0) {
    println("There are no cameras available for capture.");
    exit();
  } else {
    println("Available cameras:");
    for (int x=0;x&lt;cameras.length;x++) {
      println(cameras[x]);
    }

    cam = new Capture(this, cameras[0]);
    cam.start(); 
  }

  size(360,240);

  frame = createImage(cam.width,cam.height,RGB);
  destination = createImage(cam.width,cam.height,RGB);

  println("setup");

}

void draw() {
  if (cam.available() == true) {
    cam.read();
    println("cam read");
  }

  cam.loadPixels();
  frame.loadPixels();

  for(int x=0;x&lt;cam.width;x++) {
    for (int y=0;y&lt;cam.height;y++) {
      int loc = x+y*cam.width;
      frame.pixels[loc] = cam.pixels[loc];
      }
    }

  println("pixels copied");

  int threshold = 127;

  for(int x=0;x&lt;cam.width;x++) {
    for (int y=0;y&lt;cam.height;y++) {
      int loc = x+y*cam.width;
      if (brightness(frame.pixels[loc]) &lt;= threshold) {
        destination.pixels[loc] = color(0);
      } else {
        destination.pixels[loc] = color(255);
      }
     }
   }

  destination.updatePixels();
  image(destination,0,0);

  println("printed");
}
</code></pre>

<p>Thanks in advance!</p>

<p>P.S. The code isn't displaying correctly in my browser, if it happens for anyone else I apologise! EDIT: it's working now, thanks to GoToLoop.</p>
]]></description>
   </item>
   </channel>
</rss>