ProcessingでGenerative art #50
Code
float d = 100;
float angleNoise;
void setup() {
size(800, 800);
pixelDensity(2);
colorMode(HSB, 360, 100, 100, 100);
noLoop();
rectMode(CENTER);
angleNoise = random(10);
}
void draw() {
background(360);
for (float i = 0; i < width; i+=random(2)) {
stroke(map(i, 0, width, 200, 360));
line(i, 0, i, height);
}
for (float y = d/2; y <= height; y += d*1.5) {
for (float x = d/2; x <= width; x += d*1.5) {
pushMatrix();
translate(x, y);
rotate(map(noise(angleNoise), 0, 1, -PI/2, PI/2));
drawRect(0, 0, d, d);
popMatrix();
angleNoise += 0.01;
}
}
}
void drawRect(float x, float y, float w, float h) {
if (random(1)> 0.5) {
for (float i = x - w/2; i <x + w/2; i += random(1)) {
stroke(9, 100, map(i, x - w/2, x+w/2, 50, 100), 50);
line(i, y - h/2, i, y + h/2);
}
}
stroke(0);
for (float i = 0; i < 15; i++) {
float weight = random(-h/50, h/50);
float len = random(-w/2, w/2);
line(x - w/2 + len, y - h/2 + weight, x + w/2 + len, y - h/2 + weight);
line(x + w/2 + len, y + h/2 + weight, x - w/2 + len, y + h/2 + weight);
}
for (float i = 0; i < 10; i++) {
float weight = random(-w/50, w/50);
float len = random(-h/2, h/2);
line(x - w/2 + weight, y + h/2 + len, x - w/2 + weight, y - h/2 + len);
line(x + w/2 + weight, y - h/2 + len, x + w/2 + weight, y + h/2 + len);
}
}
void mousePressed() {
redraw();
}
void keyPressed(){
if(key == 's')saveFrame("####.png");
}
Happy coding!
応援してくださる方!いつでもサポート受け付けてます!