soulwire/sketch.js

Change Default Clear Method to ctx.clearRect()

jackrugile opened this issue · 1 comments

This might be a personal preference issue, or you might have performance reasons for using ctx.canvas.width = ctx.canvas.width for clearing - Code Reference.

However, I always find myself resetting the clear method to ctx.clearRect( 0, 0, ctx.canvas.width, ctx.canvas.height ) since that does not clear the state of the canvas. There are many simple animations I make that have initial line widths, stroke styles, or other default options that never get changed throughout the animation. It is nice not to have to redeclare those values on each loop tick.

Just something to consider, if you have other reasons for using the width clear method though, please let me know. Thanks!

Also already implemented in the coming commits! I know the width hack has always been a little contentious, though JSPerfs at the time showed it to be the fastest way to clear the canvas. This is no longer the case though and as you say, clearing the state isn't always preferable.