プチプチシートのクオリティを上げていく
亀の歩み#12
亀の歩みと称して、ジェネラティブアートの練習を投稿しているのですが、以前、亀の歩み#10として投稿したプチプチのクオリティをどうしても上げたい!
そこで、主に行った改良点は2つ。
1. 円周をグラデーションにする
2. 透明度を加える
1. に関しては前回の亀の歩み#11を利用しました。
元の作品であるクリムトの「木々の下の薔薇」がこちら。
それが、こうなった!
前回よりかはプチプチ感が増している?
ソースコード(ぐちゃぐちゃしてきちゃいました)
import generativedesign.*;
PImage img;
color[] colors;
void setup() {
size(600, 600);
colorMode(HSB, 360, 100, 100, 100);
ellipseMode(RADIUS);
strokeCap(ROUND);
img = loadImage("greenflower.jpg");
noLoop();
color whiteColor = color(0, 0, 100);
int big_rectSize = 20;
int big_tileCount = width/big_rectSize;
int small_rectSize = 1;
int small_tileCount = big_rectSize/small_rectSize;
float gradStep = 0.01;
float gradCount = TWO_PI/gradStep;
float smallRadius = big_rectSize*0.45;
float microRadius = 0.28;
// big boxes
for (int big_gridY=0; big_gridY<big_tileCount; big_gridY++) {
for (int big_gridX=0; big_gridX<big_tileCount; big_gridX++) {
// small boxes
int i = 0;
colors = new color[small_tileCount*small_tileCount];
for (int small_gridY=0; small_gridY<small_tileCount; small_gridY++) {
for (int small_gridX=0; small_gridX<small_tileCount; small_gridX++) {
int px = (int) (big_rectSize*big_gridX + small_gridX*small_rectSize);
int py = (int) (big_rectSize*big_gridY + small_gridY*small_rectSize);
colors[i] = img.get(px, py);
i++;
}
}
int j = 0;
for (int gridY=0; gridY<small_tileCount; gridY++) {
for (int gridX=0; gridX<small_tileCount; gridX++) {
fill(colors[j]);
noStroke();
rect(big_rectSize*big_gridX + gridX*small_rectSize, big_rectSize*big_gridY + gridY*small_rectSize, small_rectSize, small_rectSize);
j++;
}
}
String sortMode = GenerativeDesign.HUE;
colors = GenerativeDesign.sortColors(this, colors, sortMode);
pushMatrix();
if (big_gridY%2==0) {
translate(big_gridX * big_rectSize + big_rectSize/2,
big_gridY * big_rectSize + big_rectSize/2);
} else {
translate(big_gridX * big_rectSize,
big_gridY * big_rectSize + big_rectSize/2);
}
// draw below
// circle
for (int k=0; k<gradCount; k++) {
float grad = k*gradStep;
int colorIndex = (int) map(k, 0, gradCount, 0, sq(small_tileCount));
color fillColors = lerpColor(colors[colorIndex], whiteColor, 0.5);
fill(fillColors, 90);
ellipse(smallRadius*cos(grad), smallRadius*sin(grad), microRadius, microRadius);
}
// triangle
rotate(random(0, PI));
float x1 = 0 + random(0, 1) -1;
float y1 = -big_rectSize/3-1 + random(0, 1);
float x2 = -(big_rectSize/3)*cos(PI/6) + random(0, 1);
float y2 = (big_rectSize/3)*sin(PI/6) + random(0, 1);
float x3 = (big_rectSize/3)*cos(PI/6) + random(0, 1);
float y3 = (big_rectSize/3)*sin(PI/6) + random(0, 1);
color line1Color = lerpColor(colors[0], whiteColor, 0.3+random(0, 0.5));
color line2Color = lerpColor(colors[0], whiteColor, 0.3+random(0, 0.6));
color line3Color = lerpColor(colors[0], whiteColor, 0.3+random(0, 0.6));
stroke(line1Color, 70);
strokeWeight(random(3.0, 3.0));
line(x1-random(0,1), y1-random(0,1), x2-random(0,1), y2-random(0,1));
stroke(line2Color, 70);
strokeWeight(random(1, 1.2));
line(x2+random(0,1), y2+random(0,1), x3-random(0,1), y3-random(0, 1));
stroke(line3Color, 70);
strokeWeight(random(0.8, 1));
line(x3-random(0,1), y3-random(0,1), x1-random(0,1), y1-random(0, 1));
popMatrix();
}
}
}
この記事が気に入ったらサポートをしてみませんか?