10 examples of 'javascript clear canvas' in JavaScript

Every line of 'javascript clear canvas' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
276function clear(whichCanvas)
277{
278 var myCanvas = document.getElementById(whichCanvas);
279 var graphics = myCanvas.getContext("2d");
280
281 graphics.clearRect(0,0,512,448);
282}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

216function clearCanvas() {
217 var cxt = document.getElementById("myCanvas").getContext("2d");
218 cxt.clearRect(0, 0, canvas_width, canvas_height);
219}
97function clearCanvas(){
98 var canvas = document.getElementById("myCanvas");
99 var context = canvas.getContext("2d");
100 context.clearRect(0, 0, canvas.width, canvas.height);
101}
38function clearCanvas(){
39 ctx.clearRect(0,0,300,300);
40 addCommandToHistory('clear()');
41}
25function clearCanvas(canvas) {
26 var ctx = canvas.getContext("2d");
27 ctx.clearRect(0, 0, canvas.width, canvas.height);
28};
51clear() {
52 this.getContext().clearRect(0,0,this.canvas.width,this.canvas.height);
53}
21clearCanvas() {
22 var ctx = $('canvas')[0].getContext("2d");
23 ctx.clearRect(0, 0, INC_W, INC_H);
24}
168clear() {
169 this._ctx.clearRect(0, 0, this.width, this.height)
170 this.setActions([])
171 }
48clearCanvas() {
49 this.ctx.clearRect(0, 0, this.el.width, this.el.height);
50}
41function clearCanvas() {
42 var surfaceContext = surface.getContext('2d');
43 // Clear the canvas to White
44 surfaceContext.fillStyle = "rgb(37,170,226)"; // TODO: Make this transparent.
45 surfaceContext.fillRect(0, 0, surface.width, surface.height);
46}

Related snippets