Processing 幅と高さ

 壊滅的な英語翻訳能力を衆目に曝しながら今日はこれ。

Width and Height.

void setup()
{
 size(640,360);
}


void draw()
{
 background(127);
 noStroke();
 for(int i = 0; i < height; i+=20)
 {
  fill(129, 206,15);
  rect(0, i, width, 10);
  fill(255);
  rect(i, 0, 10, height);
 }
}


 forとか入ってきたときに"{","}"があるのと無いのとでは見やすさが違うと思うんですよ。
あるだけで、どれだけ救われた気分になるかw
柴犬の子供 (Shiba Inu, Puppy) - 無料写真検索fotoq
photo by Dakiny

構文
setup()


戻り値 void


 初期化やら環境設定の関数らしい。
プログラムが始まった時に一度だけ呼ばれる。

構文
draw()


戻り値 void


 setup()の後に自動的に呼ばれる関数。
説明のところに細々したのが書いてあるけど、noLoop()で止まり、redraw()で呼び出し、loop()で停止解除みたい。
frameRate()関数でdraw()の実行頻度を変える。

構文
noStroke()


戻り値 void


 ストローク(境界線)を描画しなくなる。

構文
for (init; test; update) {
 statements
}


for (datatype element : array) {
 statements
}


パラメータ
init ループ開始に一度だけ実行されるステートメント
test もし評価(比較?)がtrueなら実行
update 繰り返し終了時に実行する
statements 中身
datatype 配列のデータタイプ
element 使う配列の名前
array 繰り返す配列の名前(?)


 いわゆるループ。for文。

構文
fill(rgb)
fill(rgb, alpha)
fill(gray)
fill(gray, alpha)
fill(v1, v2, v3)
fill(v1, v2, v3, alpha)


パラメータ
rgb int: color variable or hex value
alpha float: opacity of the fill
gray float: number specifying value between white and black
v1 float: red or hue value (depending on current color mode)
v2 float: green or saturation value (depending on current color mode)
v3 float: blue or brightness value (depending on current color mode)


戻り値 void


 呼んだあとの図形描画が塗りつぶしになる。


 ちょっといじってこんな風にしてみた。
マウスの上下で動く。

int Y;

void setup()
{
 size(640,360);
}

void draw()
{
 background(123);
 noStroke();
 Y = mouseY/10+1;
 for(int i = 0; i < height; i+=Y)
 {
  fill(129, 206,15);
  rect(0, i, width, 10);
  fill(255);
  rect(i, 0, 10, height);
 }
}