Your browser doesn't support canvas.
Refactorings/code rules applied
Replace Magic Number with Symbolic Constant
, also G25 in Clean Code
Be consistent with formatting
Dependency injection pattern
G19: Use explanatory values
replace multiple booleans with state field
G20 Functions names should say what they do
and "prefer fewer arguments"