Skip to content

Instantly share code, notes, and snippets.

@tado
Last active March 31, 2017 08:30
Show Gist options
  • Save tado/500990dce0f204058d86c70ddbb3873a to your computer and use it in GitHub Desktop.
Save tado/500990dce0f204058d86c70ddbb3873a to your computer and use it in GitHub Desktop.
Generative Book Cover (http://amzn.asia/bUpMMUO)
import processing.pdf.*; //PDF Exportライブラリのインポート
float strength = 1400.0; //ノイズの強さ
int step = 6; //グリッドの細かさ
float noiseScale = 0.002; //パーリンノイズのスケール
void setup() {
size(1920, 1200);
noLoop(); //ループさせない(1フレームのみ書き出す)
}
void draw() {
//PDF書き出し
beginRecord(PDF, "output.pdf");
//描画の設定
background(255);
stroke(191);
noFill();
//2次元のパーリンノイズをベジェ曲線で描画
for (int j = -height*2; j < height*2; j += step) {
beginShape();
for (int i = -width/2; i < width * 1.5; i += step) {
float noise = noise(i * noiseScale, j * noiseScale) * strength;
curveVertex(i, j + noise + (i * 0.5));
}
endShape();
}
//PDFの記録を終了してファイルに書き出し
endRecord();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment