class App_20200916205824 { constructor( canvasId ) { this.cc = document.getElementById( canvasId ).getContext( "2d" ); this.flg = true; } start() { this.timerId = setInterval( function() { this.draw( this.cc ); this.flg = ! this.flg; }.bind( this ), 500 ); } stop() { clearInterval( this.timerId ); } draw( cc ) { cc.fillStyle = this.flg ? "orange" : "green"; cc.fillRect( 30, 30, 130, 130 ); } }