スポンサーリンク

Processing

randomGaussian関数を使用してみる。

投稿日:

randomGaussianを使用してスケッチを作成してみました。
floatは浮動小数点数というのを覚えつつの記載。

ちなみに公式サイトよりrandomGaussian関数は下記より。

関数の説明

【英 語】
Returns a float from a random series of numbers having a mean of 0 and standard deviation of 1. Each time the randomGaussian() function is called, it returns a number fitting a Gaussian, or normal, distribution. There is theoretically no minimum or maximum value that randomGaussian() might return. Rather, there is just a very low probability that values far from the mean will be returned; and a higher probability that numbers near the mean will be returned.

【翻 訳】
0の平均と1 randomGaussian ( )関数が呼び出されるたびに、標準偏差を持つ数字のランダム系列からfloatを返し、それはガウスのフィッティング番号、または通常、分布を返します。 randomGaussian ()が返される可能性がありますという最小値または最大値は、理論的にはありません。むしろ、返される平均値から遠い値だけでは非常に低い可能性があります。より高い確率の平均に近い数字が返されること。

この関数を使用していけばちょっとはインタラクティブチックな描画を作成できるかなと。

実行コード

int RATIO = 80; //長さ 80px
int COLOR = 255; //255色
float x1, y1, x2, y2; //描画位置
float r1, g1, b1; //色の設定

void setup() {
  size(640, 360);
  background(255);
  frameRate(1000); //フレームレート
}

void draw() {
  x1 = width/2 + randomGaussian()*RATIO;
  y1 = height/2 + randomGaussian()*RATIO;
  x2 = width/2 + randomGaussian()*RATIO;
  y2 = height/2 + randomGaussian()*RATIO;

  r1 = randomGaussian()*COLOR;
  g1 = randomGaussian()*COLOR;
  b1 = randomGaussian()*COLOR;
  stroke(r1,g1,b1, 30);
  line(x1, y1, x2, y2);

  /*saveFrame("frames/######.tif");*/
 

実行結果

ここまで来たら数値をいじれば楽しいものが出来ないかなと思っているので、ここからForkしていきます。

Originally posted 2016-01-15 17:25:24.

スポンサーリンク

-Processing
-,

Copyright© office606 , 2023 All Rights Reserved Powered by STINGER.