Generative Art #160
Code
import java.util.*;
ArrayList<Particle> particles;
int n = 120;
void setup() {
size(900, 900);
pixelDensity(2);
generate();
}
void draw() {
Iterator<Particle> it = particles.iterator();
while (it.hasNext()) {
Particle p = it.next();
p.run();
if (p.isDead()) {
it.remove();
}
}
}
void generate() {
particles = new ArrayList<Particle>();
background(#292929);
circles();
tile();
ripple();
noiseSeed((int)random(100000));
}
void ripple() {
int c = 7;
for (int i=0; i<n; i ++) {
float x = width/2, y = height/2;
float s = map(i, 0, c-1, 200, width*1.5);
float hs = s/2;
color col = getCol();
for (float a = 0; a < TAU; a += 0.005) {
particles.add(new Particle(x+hs*cos(a), y+hs*sin(a), col));
}
}
}
void circles() {
for (int i=0; i<210; i++) {
fill(getCol());
noStroke();
circle(random(width), random(height), random(random(random(100))));
}
}
void dottedLine(float x1, float y1, float x2, float y2) {
float c = 10;
for (int i = 0; i < c; i ++) {
float x = lerp(x1, x2, i/c);
float y = lerp(y1, y2, i/c);
point(x, y);
}
}
void tile() {
int c = 50;
float w = width/c;
noFill();
for (int j = 0; j < c; j++) {
for (int i = 0; i < c; i++) {
stroke(getCol());
if (random(1) < 0.5) {
if (random(1) < 0.5) dottedLine(i*w, j*w, i*w+w, j*w+w);
else line(i*w, j*w, i*w+w, j*w+w);
} else {
if (random(1) < 0.5) dottedLine(i*w+w, j*w, i*w, j*w+w);
else line(i*w+w, j*w, i*w, j*w+w);
}
}
}
}
void mousePressed() {
generate();
}
void keyPressed() {
if (key == 's')saveFrame("####.png");
}
int[] colors = {#5782a8, #f2d67b, #f2bd79, #ef9e6b, #d67568};
int getCol() {
return colors[(int)random(colors.length)];
}
//---------------------------------------------------------
class Particle {
PVector pos;
float step;
float lifeSpan;
color col ;
float angle;
float noiseScale, noiseStrength, noiseZ;
float noiseStep;
Particle(float x, float y, color col) {
pos = new PVector(x, y);
step = 1;
angle = random(10);
lifeSpan = 100;
noiseScale = 1000;
noiseStrength = 60;
noiseStep = 0.001;
noiseZ = 0;
this.col = col;
}
void show() {
noStroke();
fill(col, lifeSpan);
circle(pos.x, pos.y, 1);
}
void move() {
angle = noise(pos.x/noiseScale, pos.y/noiseScale, noiseZ) * noiseStrength;
pos.x += cos(angle) * step;
pos.y += sin(angle) * step;
lifeSpan -= 0.5;
noiseZ += noiseStep;
}
boolean isDead() {
if (lifeSpan < 0.0) {
return true;
} else {
return false;
}
}
void run() {
show();
move();
}
}
波紋状にノイズぅぅ
Happy coding!
応援してくださる方!いつでもサポート受け付けてます!