パフォーマンス計測用

http://d.hatena.ne.jp/alpha_neet/20100617/1276777012
のコードをループ化&FrameRate出力化

http://d.hatena.ne.jp/alpha_neet/20100617/1276777012
のコードをループ化&FrameRate出力化

int w = 200, h = 300;

PImage flip = createImage(w, h, ARGB);
PGraphics g = createGraphics(w, h, JAVA2D);

void setup(){
frameRate(1000);
size(w<<1, h, P2D);
}

void draw(){
println(frameRate);

// 適当になんか描く
g.beginDraw();
g.colorMode(HSB, w);
for(int i=0; i<w; i++) {
  g.stroke(i, w, w);
  g.line(i, 0, i, h);
}
g.textSize(w>>2);
g.fill(0);
g.text("aiueo", w>>2, h>>1);
g.endDraw();

image(g, 0, 0);

// 反転処理
for(int ly=0; ly<h; ly++) {
for(int lx=0; lx<w; lx++) { 
  int i = lx + (ly*w);
  int j= (w-lx-1) + (ly*w); // -1を忘れずに
  flip.pixels[i] = g.pixels[j];
}}

image(flip, w, 0);
stroke(0); line(w, 0, w, h);
}