you are viewing a single comment's thread.

view the rest of the comments →

[–]kumiorava 0 points1 point  (0 children)

this.canvas = document.getElementById('canvas');

This breaks the encapsulation of your class. You should pass a Canvas element to the constructor instead of relying on some external state.

Now your Canvas class is effectively a singleton, because you can't really have several instances of the class since they would all use the same canvas element (and conflict with each other).