Sketch.js

Sketch.js is an easy-to-use jQuery plugin that allows you to create canvases upon which visitors can draw. The code is partially inspired by William Malone's drawing app tutorial as well as CanvasPaint.

Installation

To use Sketch.js in your project, just grab the latest sketch.js (or minified) from GitHub and include it in your project after jQuery.

Documentation

To see detailed documentation, take a look at the annotated source code.

Simple Example

Click and drag in the box below to draw a simple black line.

Changing Color/Size, Downloading Image

Sketch.js makes it very easy to create links that function as tool buttons. By default, any link that has a href tag that points to the ID of the converted canvas will automatically be considered a tool link. If the link has a data-color attribute then clicking it will change the color. Similarly, a data-size attribute will change the brush size.

Setting the data-download on a tool link to jpeg or png will create a download button for the specified format.

3 5 10 15

Tools Example

Click buttons to switch between tools.

Compatibility

Sketch.js has been tested on Chrome (OS X), Firefox (OS X), Safari (OS X), Android Browser (Honeycomb 3.1). It suffers significant performance degradation on mobile browsers due to general HTML5 Canvas performance issues.

License

Copyright (C) 2011 by Michael Bleigh and Intridea, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.