Created
March 24, 2019 12:25
-
-
Save reona396/fc4643eb9d924e54c687e79ced7319ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Particle[] particles; | |
int particlesNum = 1000; | |
color[] colors = new color[4]; | |
PImage[] img = new PImage[8]; | |
int imgIndex = 0; | |
PImage copyImg; | |
float xoff = 0.0; | |
int imgW = 0; | |
int imgH = 0; | |
void setup() { | |
fullScreen(2); | |
particles = new Particle[particlesNum]; | |
for (int i = 0; i < particlesNum; i++) { | |
particles[i] = new Particle(i); | |
} | |
imageMode(CENTER); | |
for (int j = 0; j < img.length; j++) { | |
img[j] = loadImage("./Assets/" + nf(j, 2) + ".jpg"); | |
} | |
colors[0] = color(0, 255, 255); | |
colors[1] = color(255, 255, 255); | |
colors[2] = color(255, 0, 255); | |
colors[3] = color(0, 0, 30); | |
imgW = img[imgIndex].width; | |
imgH = img[imgIndex].height; | |
} | |
void draw() { | |
background(0); | |
if (frameCount % 5 == 0) { | |
imgIndex = floor(random(img.length)); | |
imgW = img[imgIndex].width; | |
imgH = img[imgIndex].height; | |
} | |
for (int i = 0; i < imgH; i+=2) { | |
xoff += 0.03; | |
int copyX = 0; | |
int copyY = i; | |
int copyW = imgW; | |
int copyH = 2; | |
float copyD = noise(xoff) * 50; | |
copyImg = img[imgIndex].get(copyX, copyY, copyW, copyH); | |
image(copyImg, copyX + copyD+copyW/2, copyY); | |
} | |
noStroke(); | |
fill(0); | |
beginShape(); | |
vertex(0, 0); | |
vertex(width, 0); | |
vertex(width, height); | |
vertex(0, height); | |
beginContour(); | |
for (int t = 360; t >0; t--) { | |
vertex(width/2 + 200 * cos(radians(t)), height/2+200*sin(radians(t))); | |
} | |
endContour(); | |
endShape(CLOSE); | |
for (Particle pa : particles) { | |
pa.display(); | |
pa.move(); | |
} | |
} | |
class Particle { | |
float x; | |
float y; | |
float R; | |
float r = random(5, 30); | |
float theta = random(360); | |
int colorIndex; | |
int index; | |
int dir = random(10) >= 5 ? -1 : 1; | |
float thetaSpeed = random(0.1, 0.8); | |
float RsinTheta = random(360); | |
float Rsin; | |
Particle(int tmpIndex) { | |
index = tmpIndex; | |
colorIndex = index % colors.length; | |
R = 150 + (colors.length - colorIndex) * 20 + random(-20, 20); | |
} | |
void display() { | |
Rsin = 5 * sin(radians(RsinTheta)); | |
x = (R + Rsin) * cos(radians(theta)); | |
y = (R + Rsin) * sin(radians(theta)); | |
push(); | |
translate(width/2, height/2); | |
noStroke(); | |
fill(colors[colorIndex]); | |
ellipse(x, y, r, r); | |
pop(); | |
} | |
void move() { | |
theta += dir * thetaSpeed; | |
RsinTheta += 5; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment