generativeart_023
// 作品概要:
// 円を並べる
// (C)2023 sakuzo_arts
// Global変数
String APPNAME = "generativeart_023";
float CIRCLE_X; // 円の中心の座標X
float CIRCLE_Y; // 円の中心の座標Y
int LINES_NUM; // 行数
// セットアップ
void setup() {
size(800, 800);
noLoop();
background(255);
}
// 描画
void draw() {
LINES_NUM = 20;
drawCircle(LINES_NUM);
drawFooter();
}
// 円をを描画する関数
void drawCircle(int LINES_NUM){
// 背景色設定
background(255);
noStroke();
noFill();
// 円を描画する始点を設定
CIRCLE_X = 0;
CIRCLE_Y = 0;
// 円の直径を設定
float CIRCLE_DIAMETER = height / LINES_NUM;
// 円を描画する処理
for(int i = 0; i < LINES_NUM; i = i + 1){
for (int j = 0; j < width + 20; j = j + 20) {
fill(getColor());
circle(CIRCLE_X + j, CIRCLE_Y + noise(j), random(10, CIRCLE_DIAMETER * 0.8));
}
CIRCLE_Y = CIRCLE_Y + CIRCLE_DIAMETER;
}
}
// 色を設定する関数
color getColor(){
float COLOR_R = 255;
float COLOR_G = random(129, 255);
float COLOR_B = random(0, 128);
float COLOR_A = random(128, 192);
color COLOR_RGBA = color(COLOR_R, COLOR_G, COLOR_B, COLOR_A);
return COLOR_RGBA;
}
// フッターを表示する関数
void drawFooter(){
// 長方形の描画方法をデフォルトに戻す
rectMode(CORNER);
// 長方形を背景として描画する
noStroke();
fill(255, 255, 255, 192);
rect(0, height - 45, width, 45);
// 作品名
textAlign(LEFT, BOTTOM);
textSize(20);
fill(64);
text(APPNAME, 30, height - 10);
// 著作権表示
textAlign(RIGHT, BOTTOM);
textSize(20);
fill(64);
text("(C)2023 sakuzo_arts", width - 30, height - 10);
}
// キー操作でイベントを実行する関数
void keyPressed(){
// スペースキーを押下で再描画
if(key == ' '){
redraw();
}
// Shift+sキーを押下で画像保存
if(key == 'S'){
int Y = year();
int M = month();
int D = day();
int h = hour();
int m = minute();
int s = second();
String FILENAME = APPNAME + "-" + Y + nf(M, 2) + nf(D, 2) + nf(h, 2) + nf(m, 2) + nf(s, 2);
saveFrame(FILENAME + ".png");
}
}
この記事が気に入ったらサポートをしてみませんか?