Pure Java random string code to Processing random string code

Actually Java can have keyword class inside a function!

However its usage is rare & not so many folks know about it: :nerd_face:

void settings() {
  size(600, 400);
  noLoop();

  class classInsideFunction extends PApplet {
    public void settings() {
      size(400, 300);
      println(sketchPath());
    }

    public void setup() {
      frameRate(1);
    }

    public void draw() {
      background((color) random(#000000));
    }
  }

  final String[] switches = {
    ARGS_SKETCH_FOLDER + '=' + sketchPath(), 
    ARGS_LOCATION + "=100,100", 
    "" 
  };

  runSketch(switches, new classInsideFunction());
}

void draw() {
  background((color) random(#000000));
}

void mousePressed() {
  redraw = true;
}

void keyPressed() {
  mousePressed();
}
1 Like