Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.javascript Subject: Re: Problems with Canvas fade in Date: Sat, 14 Nov 2020 16:28:35 +0100 Lines: 19 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: individual.net LssIUoB1dCaGguKl4SWIQQxk9faOdjN038Ixf0qMdORIxdl2Qx Cancel-Lock: sha1:OXH22oNAG9/aMA5/92EJ5noIrNA= In-Reply-To: Xref: csiph.com comp.lang.javascript:39142 Michael Haufe (TNO): > On Friday, November 13, 2020 at 2:36:17 AM UTC-6, Arno Welzel wrote: > >> Also clearing the canvas is not be done by setting its width. Yes, >> setting the width or height will clear it. But this is more a side >> effect than an official way to do this. A better approach: >> >> ctx.fillStyle = "rgb(0, 0, 0)"; >> ctx.fillRect(0, 0, canvas.width, canvas.height); > > ctx.clearRect(x, y, width, height); is more direct. I suspect faster as well. Does clearRect() also use the current fill style? -- Arno Welzel https://arnowelzel.de