Guest User

Untitled

a guest
Apr 9th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. class Chain {
  2.   final float divX = round(random(-1, 1)); //how far apart each circle is from the previous
  3.   final float divY = round(random(-1, -.25));
  4.   PVector velocity = new PVector (divX, divY);
  5.  
  6.   final int decayRt = round(random(2,5));
  7.   float spray = round(random(-1.75, 1.75));
  8.   int rad = round(random(15, 30)); //The radius of the cirlc in the beginning
  9.  
  10.   int xpos = mouseX + round(random(-15, 15)); //the initial X pos
  11.   int ypos = mouseY + round(random(-15, 15)); //the initial y pos
  12.   PVector location = new PVector(xpos, ypos);
  13.  
  14.   color c;
  15.  
  16.   void display() {
  17.     while (rad > 1) {
  18.      
  19.       location.add(velocity);
  20.       location.add(velocity);
  21.       velocity.mult(spray);
  22.       rad = rad - decayRt;
  23.  
  24.       ellipse(location.x, location.y, rad, rad);
  25.       fill(c);
  26.      
  27.     }
  28.   }
  29. }
  30.  
  31. int listSize = 50;
  32. Chain [] clist;
  33.  
  34. void setup() {
  35.   size (1200, 1000);
  36.   noStroke();
  37. }
  38.  
  39. void draw() {
  40.   if (mousePressed == true) {
  41.     int r = 120;
  42.     int g = round(random(190, 200));
  43.     int b = 100;
  44.  
  45.     clist = new Chain [listSize];
  46.     for (int i = 0; i < listSize; i++) {
  47.       clist[i] = new Chain();
  48.       clist[i].c = color(r, g, b);
  49.     }
  50.  
  51.     for (int i = 0; i< listSize; i++) {
  52.       clist[i].display();
  53.     }
  54.   }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment