ミラー画像

http://codetter.com/?p=636
を高速化&簡潔化

http://codetter.com/?p=636
を高速化&簡潔化

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(g, w*2, 0,-w,h);//反転させて貼る。
stroke(0); line(w, 0, w, h);
}