Socket
Book a DemoInstallSign in
Socket

clear-canvas

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clear-canvas

Clear Canvas.

latest
Source
npmnpm
Version
1.0.4
Version published
Weekly downloads
4
33.33%
Maintainers
1
Weekly downloads
 
Created
Source

clear-canvas

Build Status npm version

Clear canvas.

Installation

npm install clear-canvas --save

Usage

var clear = require('clear-canvas');

clear(ctx); // ctx is canvas 2D context.

Demo

Checkout the live demo.

clear = require('clear-canvas');

//canvas setup
var canvas  =  document.createElement('canvas');
canvas.width = '500';
canvas.height = '300';
canvas.style.outline = "1px solid black";
document.body.appendChild(canvas);

// Get the context.
var ctx = canvas.getContext('2d');

// Draw a triangle.
ctx.beginPath();
ctx.moveTo(20,20);
ctx.lineTo(200,20);
ctx.lineTo(120,120);
ctx.closePath();
ctx.stroke();

// Clear the canvas after 1000ms.
setTimeout( function() {clear(ctx, true);}.bind(this), 1000);

API

clear(ctx, saveTransform);

ctx : 2D canvas context.

saveTransform: [Optional] Defaults to true, need if you need to preverse the state.

Keywords

fp-dom

FAQs

Package last updated on 19 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts