Adding a function to the "Processing Animation Thread"

If I recall correctly, for simple pre-draw and post-draw hooks, a normal sketch can also use registerMethod() with pre() and post(), just like a library.

I’m not sure if the lightweight form is useful for your application.

int x;
void setup() {
  registerMethod("post", this);
}
void draw() {
  println(x);
}
void post() {
  x = x+1;
}
1 Like