ジェネラティブ・アート [1]
[普及版]ジェネラティブ・アート―Processingによる実践ガイド
- 作者: マット・ピアソン,Matt Pearson,久保田晃弘,沖啓介
- 出版社/メーカー: ビー・エヌ・エヌ新社
- 発売日: 2014/11/21
- メディア: 単行本(ソフトカバー)
- この商品を含むブログ (1件) を見る
- 始める。
- Download \ Processing.org から Processing の開発環境をダウンロード
- 2.1 Processing とは?
- hello world 代わりの円。
ellipse(25, 25, 50, 50);
- 2.2 プログラムでお絵描き の写経
// settings size(500, 300); smooth(); background(230); float centX = width / 2; float centY = height / 2; // cross lines stroke(130, 0, 0); strokeWeight(1); line(centX - 70, centY - 70, centX + 70, centY + 70); line(centX + 70, centY - 70, centX - 70, centY + 70); // circle stroke(0, 125); strokeWeight(6); fill(250, 150); ellipse(centX, centY, 50, 50);
- 2.3 構造、論理、アニメーション の写経
- Processingでは、フレームループによって連続的に画面を再描画している。
- setup() が起動時に呼ばれ、draw() がフレームごとに繰り返し呼ばれる。
- frameRate 関数で、draw() の呼び出し間隔を設定可能 (12, 24, 25, 30 が一般的)
int diam = 10; float centX, centY; void setup() { size(500, 300); frameRate(24); smooth(); background(180); centX = floor(width / 2); centY = floor(height / 2); stroke(0); strokeWeight(1); fill(255, 25); // noFill(); strokeCap(SQUARE); for (int h = 10; h <= (height - 15); h += 10) { stroke(0, 255 - h); line(10, h, width - 20, h); stroke(255, h); line(10, h + 4, width - 20, h + 4); } stroke(0, 255 - h); } void draw() { if (diam <= 400) { // background(180); ellipse(centX, centY, diam, diam); // println(diam); diam += 10; } }