Created
January 8, 2020 23:07
-
-
Save moritzebeling/8bc7c8ab5db6fa22f54dd1580bb704f6 to your computer and use it in GitHub Desktop.
p5 blinking cell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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