Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int num = 2, parts = 3000, frms = 100;
- PGraphics[] pg = new PGraphics[num];
- PVector[] start = new PVector[parts];
- PVector[] end = new PVector[parts];
- float sz = 10, theta;
- void setup() {
- size(540, 540, P2D);
- blendMode(SCREEN);
- createGraphics(0, "YES?");
- createGraphics(1, "NO?");
- createParticles(0);
- createParticles(1);
- }
- void draw() {
- randomSeed(455);
- background(0);
- noStroke();
- for (int i=0; i<parts; i++) {
- float l = map(sin(theta), -1, 1, 0, 1);
- PVector middle = PVector.lerp(end[i], start[i], l);
- switch(i%3) {
- case 0:
- fill(255,0,0);
- break;
- case 1:
- fill(0,255,0);
- break;
- case 2:
- fill(0,0,255);
- break;
- }
- ellipse(middle.x, middle.y, sz*random(1, 3), sz*random(1, 3));
- }
- theta += TWO_PI/frms;
- if (frameCount<=frms) saveFrame("/Volumes/Anim/image-###.gif");
- }
- void createGraphics(int i, String str) {
- pg[i] = createGraphics(width, height);
- pg[i].beginDraw();
- pg[i].background(255);
- pg[i].fill(0);
- pg[i].textSize(height*.4);
- pg[i].textAlign(CENTER, CENTER);
- pg[i].text(str, width/2, height*.4);
- pg[i].endDraw();
- }
- void createParticles(int i) {
- int counter = 0;
- while (counter<start.length) {
- int x = (int) random(width);
- int y = (int) random(height);
- color c = pg[i].get(x, y);
- if (brightness(c)<20) {
- if (i==0) {
- start[counter] = new PVector(x, y);
- } else {
- end[counter] = new PVector(x, y);
- }
- counter++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement