Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Chain {
- final float divX = round(random(-1, 1)); //how far apart each circle is from the previous
- final float divY = round(random(-1, -.25));
- PVector velocity = new PVector (divX, divY);
- final int decayRt = round(random(2,5));
- float spray = round(random(-1.75, 1.75));
- int rad = round(random(15, 30)); //The radius of the cirlc in the beginning
- int xpos = mouseX + round(random(-15, 15)); //the initial X pos
- int ypos = mouseY + round(random(-15, 15)); //the initial y pos
- PVector location = new PVector(xpos, ypos);
- color c;
- void display() {
- while (rad > 1) {
- location.add(velocity);
- location.add(velocity);
- velocity.mult(spray);
- rad = rad - decayRt;
- ellipse(location.x, location.y, rad, rad);
- fill(c);
- }
- }
- }
- int listSize = 50;
- Chain [] clist;
- void setup() {
- size (1200, 1000);
- noStroke();
- }
- void draw() {
- if (mousePressed == true) {
- int r = 120;
- int g = round(random(190, 200));
- int b = 100;
- clist = new Chain [listSize];
- for (int i = 0; i < listSize; i++) {
- clist[i] = new Chain();
- clist[i].c = color(r, g, b);
- }
- for (int i = 0; i< listSize; i++) {
- clist[i].display();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment