ProcessingでGenerative art #73
画像加工あり
Code
int count = 3;
int actRandomSeed = 0;
int drawMode = 1;
void setup() {
size(800, 800);
pixelDensity(2);
colorMode(HSB, 360, 100, 100, 100);
}
void draw() {
randomSeed(actRandomSeed);
background(360);
divideRect(10, 10, width-10, 10, width - 10, height - 10, 10, height - 10, count);
}
void divideRect(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, int n) {
if (n == 1) {
if (drawMode == 1) {
strokeWeight(3);
stroke(0);
if (random(1) > 0.66) {
fill(0, 100, 100);
} else if (random(1) >0.33) {
fill(240, 100, 100);
} else {
fill(58, 100, 100);
}
}
if (drawMode == 2) {
noStroke();
if (random(1) > 0.66) {
fill(0, 100, random(75, 100));
} else if (random(1) >0.33) {
fill(236, 100, random(75, 100));
} else {
fill(360);
}
}
if (drawMode == 3) {
strokeWeight(1);
stroke(0);
if (random(1) > 0.75) {
fill(64, 99, 100);
} else if (random(1) >0.7) {
fill(210, 100, 100);
} else if (random(1) >0.65) {
fill(119, 96, 67);
} else if (random(1) >0.6) {
fill(0);
} else if (random(1) >0.4) {
fill(316, 100, 100);
} else {
fill(360);
}
}
beginShape();
vertex(x1, y1);
vertex(x2, y2);
vertex(x3, y3);
vertex(x4, y4);
endShape(CLOSE);
if (drawMode == 3) {
int d = 5;
fill(0);
noStroke();
ellipse(x1, y1, d, d);
ellipse(x2, y2, d, d);
ellipse(x3, y3, d, d);
ellipse(x4, y4, d, d);
}
}
n--;
if (n > 0) {
float randomPointX = map(randomGaussian(), -5, 5, (x1+x4)/2, (x2+x3)/2);
float randomPointY = map(randomGaussian(), -5, 5, (y1+y2)/2, (y3+y4)/2);
divideRect(x1, y1, (x2+x1)/2, ( y1+y2)/2, randomPointX, randomPointY, (x1+x4)/2, (y4+y1)/2, n);
divideRect((x2+x1)/2, ( y1+y2)/2, x2, y2, (x2+x3)/2, (y2+y3)/2, randomPointX, randomPointY, n);
divideRect(randomPointX, randomPointY, (x2+x3)/2, (y2+y3)/2, x3, y3, (x3+x4)/2, (y3+y4)/2, n);
divideRect((x1+x4)/2, (y1+y4)/2, randomPointX, randomPointY, (x3+x4)/2, (y3+y4)/2, x4, y4, n);
}
}
void mousePressed() {
actRandomSeed = (int)random(100000);
}
void keyPressed() {
if (key == 's')saveFrame("####.png");
if (key == '1')drawMode = 1;
if (key == '2')drawMode = 2;
if (key == '3')drawMode = 3;
if (keyCode == UP)count += 1;
if (keyCode == DOWN)count -= 1;
}
Happy coding!
応援してくださる方!いつでもサポート受け付けてます!