Advertisement
xeromino

yesno

Oct 22nd, 2015
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.52 KB | None | 0 0
  1. int num = 2, parts = 3000, frms = 100;
  2. PGraphics[] pg = new PGraphics[num];
  3. PVector[] start = new PVector[parts];
  4. PVector[] end = new PVector[parts];
  5. float sz = 10, theta;
  6.  
  7. void setup() {
  8.   size(540, 540, P2D);
  9.   blendMode(SCREEN);
  10.   createGraphics(0, "YES?");
  11.   createGraphics(1, "NO?");
  12.   createParticles(0);
  13.   createParticles(1);
  14. }
  15.  
  16. void draw() {
  17.   randomSeed(455);
  18.   background(0);
  19.   noStroke();
  20.   for (int i=0; i<parts; i++) {
  21.     float l = map(sin(theta), -1, 1, 0, 1);
  22.     PVector middle = PVector.lerp(end[i], start[i], l);
  23.     switch(i%3) {
  24.     case 0:
  25.       fill(255,0,0);
  26.       break;
  27.     case 1:
  28.       fill(0,255,0);
  29.       break;
  30.     case 2:
  31.       fill(0,0,255);
  32.       break;
  33.     }
  34.     ellipse(middle.x, middle.y, sz*random(1, 3), sz*random(1, 3));
  35.   }
  36.   theta += TWO_PI/frms;
  37.   if (frameCount<=frms) saveFrame("/Volumes/Anim/image-###.gif");
  38. }
  39.  
  40. void createGraphics(int i, String str) {
  41.   pg[i] = createGraphics(width, height);
  42.   pg[i].beginDraw();
  43.   pg[i].background(255);
  44.   pg[i].fill(0);
  45.   pg[i].textSize(height*.4);
  46.   pg[i].textAlign(CENTER, CENTER);
  47.   pg[i].text(str, width/2, height*.4);
  48.   pg[i].endDraw();
  49. }
  50.  
  51. void createParticles(int i) {
  52.   int counter = 0;
  53.   while (counter<start.length) {
  54.     int x = (int) random(width);
  55.     int y = (int) random(height);
  56.     color c = pg[i].get(x, y);
  57.     if (brightness(c)<20) {
  58.       if (i==0) {
  59.         start[counter] = new PVector(x, y);
  60.       } else {
  61.         end[counter] = new PVector(x, y);
  62.       }
  63.       counter++;
  64.     }
  65.   }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement