1.0.4 • Published 10 years ago

clear-canvas v1.0.4

Weekly downloads
7
License
MIT
Repository
github
Last release
10 years ago

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.

1.0.4

10 years ago

1.0.3

11 years ago

1.0.2

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago