Skip to content

Instantly share code, notes, and snippets.

@antoinefortin
Created April 5, 2018 21:44
Show Gist options
  • Save antoinefortin/6b8cd2b89c77122e22ee93a4d0948a5a to your computer and use it in GitHub Desktop.
Save antoinefortin/6b8cd2b89c77122e22ee93a4d0948a5a to your computer and use it in GitHub Desktop.
[Basic Processing -Skectch]
Round[] R = new Round[5];
int circleWidth = 15;
int circleHeight = 15;
int counter = 0;
void setup() {
background(55);
size(1200,600);
for(int i = 0; i < 5; i++) {
R[i] = new Round();
R[i].posx = int(width / 2);
R[i].posy = int(height /2);
R[i].cwidth= circleWidth;
R[i].cheight = circleHeight;
R[i].update();
}
}
void draw() {
background(55);
for(int i = 0; i < 5; i++) {
//R[i].changeColor(int(random(255)), int(random(255)), int(random(255)));
R[i].move(width/ 2, height / int(random(counter)));
}
counter++;
}
class Round {
public int posx;
public int posy;
public int colour;
public int cwidth;
public int cheight;
public int R;
public int G;
public int B;
// a method for moving the rectangle
public void move(int x, int y) {
this.posx = x;
this.posy = y;
this.update();
}
public void update() {
noStroke();
fill(this.R, this.G, this.B);
ellipse(this.posx, this.posy, this.cwidth,this.cheight);
}
public void changeColor(int Rx, int Gx, int Bx) {
this.R = Rx;
this.G = Gx;
this.B = Bx;
}
public void changeShape(int cw, int ch) {
this.cwidth = cw;
this.cheight = ch;
this.update();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment