SketchIt - A mobile HTML5 doodling app
Some time ago, while using the Adobe Ideas drawing/sketching app on my iPad, an idea sprung to mind to create a mobile web-based (HTML5) sketching app. The advantage of having a web-based app is mainly that is platform-independent. That, and the fact that I had a straightforward implementation in mind, made me decide to create one: SketchIt.
Just another little fun project after creating some HTML5 games.

Functional Design
The core functionality of SketchIt had to be really straight-forward: allow the user to create some sketches, and save them as an image to his device. I defined the following core features of the app:
- Doodle using touch or mouse gestures (depending on the device)
- Pick a color to doodle with
- Choose the line-width of the pencil
- Save the sketch as an image
Starting with these features, SketchIt provides just enough functionality to be useful for people. And I wanted to keep the interface really minimalistic. There were some constraints that I laid down for myself:
- The app should work on as many devices as possible
- The application should exclusively run on the client (in the browser), no server-side activity other than downloading the application are allowed (so that the application can be ran offline)
- The codebase should be clean
Implementation
As I wanted SketchIt to be web-based and running on the client in the browser, choosing JavaScript + HTML5 for the implementation was the obvious thing to do. These technologies are supported by all major web
browsers, both on desktop computers as well as mobile devices. Not all browsers have the same grade of support, but that will fade over time (that’s an infrastructural issue).
I broke down the application logic of SketchIt into 2 modules:
- A drawing surface that allows a user to doodle on, and save its creation (Sketchpad.js)
- A color picker that allows the user to pick a color that he wants to use (ColorPicker.js)
Those 2 modules, wrapped inside a jQuery Mobile interface would become the initial version of the application. There are some other nice mobile UI frameworks, but I really like the simplicity and quality of jQuery Mobile.
Both Sketchpad.js and ColorPicker.js are open source modules, and can be retrieved from Google Code. The source code is annotated with JSDoc.
Sketchpad.js
Sketchpad.js is the module that implements the sketching surface. It is mostly fluff around the HTML5 Canvas API. With this module you can instantiate one or more sketching surfaces with a given width and height. Instance methods are provided to set the sketching color, line width, and to export the sketch to an image.
To export an image, the toDataURL method of the Canvas object is used. This returns a Base64 image representation of the Canvas, in a given (and supported) file format. Unfortunately, this method is not yet implemented in Android (<= 2.3), so saving a sketch as an image is not yet supported on Android devices. I read somewhere that Android Honeycomb (3.0) for tablets already implements the toDataURL method on the Canvas.
Example of Sketchpad.js usage (jsfiddle.net)
ColorPicker.js
ColorPicker.js instantiates a color picker, defined by a number of optional parameters: width, height, lightness and callback functions for choosing a color or mouse-over’ing a color.
Example of ColorPicker.js usage (jsfiddle.net)

Extra features
This basic implementation of SketchIt leaves room for many features on different areas:
- A local library of saved sketches (and resume editing)
- Post sketches to social networks
- Share/collaborate on sketches with friends
- Different pencil types
- …
Anyway, at least for now these are beyond the scope of this little project. You can try SketchIt on http://m.pretopia.net/sketchit