Skip to content

Instantly share code, notes, and snippets.

@moritzebeling
Created January 8, 2020 23:07
Show Gist options
  • Save moritzebeling/8bc7c8ab5db6fa22f54dd1580bb704f6 to your computer and use it in GitHub Desktop.
Save moritzebeling/8bc7c8ab5db6fa22f54dd1580bb704f6 to your computer and use it in GitHub Desktop.
p5 blinking cell
class Cell {
constructor( x, y, on = true ){
this.x = x;
this.y = y;
this.on = on;
if( this.on === false ){
this.radius = 0;
} else {
this.radius = maxRadius;
}
this.radius = 0;
}
render(){
if( this.on === false ){
return false;
} else if ( this.on === 1 ){
this.radius += 10;
if( this.radius > maxRadius ){
this.radius = maxRadius;
this.on = true;
}
} else if ( this.on === 0 ){
this.radius -= 10;
if( this.radius < 0.1 ){
this.radius = 0.05;
this.on = false;
}
}
circle( this.x, this.y, this.radius );
}
switch(){
if( this.on ){
this.on = 0;
} else {
this.on = 1;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment