Using lambda form with hype processing

Sam Pottingers development version of processing supports lambda syntax in processing ide.

import hype.*;

HDrawablePool pool;

void setup() {
  size(640, 640);
  H.init(this);
  H.background(#242424);

  pool = new HDrawablePool(100);
  pool.autoAddToStage()
    .add(new HRect(50))
    .onCreate(
    ((Object obj) -> {
    HDrawable d = (HDrawable) obj;
    d
      .strokeWeight(1)
      .stroke(#999999)
      .fill(#202020)
      .loc((int) random(width), (int) random(height));
  }
  )
  )
  .requestAll();
  H.drawStage();
  noLoop();
}

void draw() {
}

Of course we’ve been able to do that sort of stuff in JRubyArt for ages (and it looks a lot more elegant)

3 Likes