Processing 2.0 beta 8 がリリースされました
2013年2月25日 (Processingニュース)
2月25日 Processingの新しいバージョンである 2.0 beta 8 がリリースされました。
Download \ Processing.org
今回は、特に注目すべきポイントについてご紹介します。
- Retinaディスプレイがサポートされ、パフォーマンスが改善されています。
- その他複数のバグが修正されています。
それらの関数を使ったサンプルがこちら
final int RATIO = 10;
float x, y;
PGraphics g1, g2;
int SIDE=200;
int WIDTH=SIDE*2, HEIGHT=SIDE;
void setup() {
frameRate(1000);
clear();//more than 2.0b8 (If less than 2.0b7 background(0, 0, 0, 0))
size(WIDTH, HEIGHT);
stroke(255);
g1 = createGraphics(SIDE, SIDE);
g1.beginDraw();
g1.clear();//more than 2.0b8 (If less than 2.0b7 background(0, 0, 0, 0))
g1.stroke(255);
g1.endDraw();
g2 = createGraphics(SIDE, SIDE);
g2.beginDraw();
g2.clear();//more than 2.0b8 (If less than 2.0b7 background(0, 0, 0, 0))
g2.stroke(255);
g2.endDraw();
}
void draw() {
g1.beginDraw();
x =g1.width/2+ random(-1, 1)*RATIO;
y =g1.height/2+ random(-1, 1)*RATIO;
g1.point(x, y);
g1.endDraw();
image(g1, 0, 0);
g2.beginDraw();
x =g2.width/2+ randomGaussian()*RATIO;//more than 2.0b8
y =g2.height/2+ randomGaussian()*RATIO;//more than 2.0b8
g2.point(x, y);
g2.endDraw();
image(g2, width/2, 0);
line(width/2, 0, width/2, height);
}

clear()はbackground(0, 0, 0, 0)と同じです。
randomGaussian()は平均 0.0、標準偏差 1.0 のガウス(正規)分布の、擬似乱数値を求めます。
正規分布 – Wikipedia
PGraphicsを使って少々コードが読みにくいかもしれないので、簡易版を載せます。
final int RATIO = 10;
float x, y;
void setup() {
clear();//more than 2.0b8 (If less than 2.0b7 background(0, 0, 0, 0))
size(200, 200);
stroke(255);
frameRate(1000);
}
void draw() {
//randomGaussian() version
x =width/2+ randomGaussian()*RATIO;//more than 2.0b8
y =height/2+ randomGaussian()*RATIO;//more than 2.0b8
////random() version
// x =width/2+ random(-1,1)*RATIO;
// y =height/2+ random(-1,1)*RATIO;
point(x, y);
}





最近のブログコメント