Skip to main content
100%

Freehand drawing

✓ Published0🌍 Public
TThanaporn-sk
Last edited Jul 12, 2015
Created on Nov 15, 2016

This freehand drawing application lets users create smooth, colored lines with a mouse, stylus, or finger, using a palette of Colorbrewer Dark2 colors and a trash button to clear the canvas. It maintains all drawing data in a DOM-independent JavaScript object, logging completed lines to the console. Built with D3 v3, it renders strokes as SVG paths via `d3.svg.line()` with basis interpolation, and uses `d3.behavior.drag` to capture pointer movement. Two stacked SVG layers separate the drawing surface from UI controls, preventing accidental marks when interacting with the interface.

AI-generated description

A simple freehand drawing application, based on Bostock's Line Drawing gist.

Use your stylus, fingers or mouse to draw. The color of the line can be changed by interacting with the color palette, and the canvas can be cleared by clicking the trash in the upper-right corner of the UI.

The application uses two stacked SVG elements, one for the UI and one for the canvas. This is used to disable drawing when interacting with UI elements.

Unlike Bostock's example, this application maintains a DOM-independent object to store all the drawing's data (just look at the JavaScript console each time you complete a line).

Colors are from Colorbrewer's Dark2 palette.

Similar vizzes