Skip to content

HuilingP/creative-coding_homework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

creative-coding_homework

//creating an array Cell[] myCells = new Cell[1500]; //No. of cells

Cell myCell;

//CIRCLE float a; float b; float c; float x; float colred = 100; float colgreen = 0; float colblue= 100;

void setup (){ background (0); size (500,500); frameRate(50);

//populating the array for (int i=0; i<myCells.length; i++) { myCells[i] = new Cell(); } }

void draw (){

//for loop for (int i=0; i<myCells.length; i++) { myCells[i].display(); myCells[i].update();

}

pushMatrix(); //The pushMatrix() function saves the current coordinate system to the stack and popMatrix() restores the prior coordinate system. a=random(4); c=300; b=(c/2); x=random(500);

translate(width/2, height/2); rotate(PI/a); noFill();

if(mouseX>width/2){ colred=colred+1; }else {colred=colred-1; }

if(mouseX<width/2){ colblue=colgreen+1; }else {colblue=colgreen-1; }

stroke(colred, colgreen, colblue); strokeWeight(.1); rect(-b, -b, c, c);

stroke(0); line(b,b,c,c); popMatrix();

c=c+x;

} //

class Cell {

float xlocation; float ylocation; float dia; boolean issed; float cellred, cellgreen, cellblue; float lineweight;

//then we construct it- using a constructor

Cell() {

xlocation=250; //origin of cells
ylocation=250;
dia=random(1); // diameter of cells
issed=false;
cellgreen=random(230);    //random prefix to change colour randomly
cellblue=random(220);    
//lineweight=0.1;

}

void display() { noStroke(); fill(220, cellgreen, cellblue); ellipse(xlocation, ylocation, dia, dia); }

void update(){ xlocation = xlocation + random(-5,5); //increase speed/ direction ylocation = ylocation + random(-5,5); //increase speed/ direction }

}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published