Paul Krill
Editor at Large

New JavaScript library invites coders to play with Canvas

news
Feb 22, 20172 mins

The Sandpit library uses the canvas 2D element for creative coding

sand castle on harbour island
Credit: Amanda B

Looking to blur the line between technology and art, the Sandpit library for creative coding uses JavaScript and the canvas 2D element.

Accessible on GitHub or via NPM, and built in ECMAScript 6, Sandpit is still in development with an API likely to change before the 1.0 release. “The goal of Sandpit is to normalize and simplify the process of creating coding — using code to make pretty things,” the documentation states. “This usually takes the form of drawing onto the Canvas element, in either a 2D or 3D context.” Sandpit uses the dat.GUI, a lightweight GUI for changing variables in JavaScript, to manage settings.

To get started quickly with Sandpit in an ES6 environment, builders Charlie Gleason and Glen Maddern recommend using create-react-app, a Facebook incubator project for creating React JavaScript apps with no build configuration; a demo of Sandpit uses create-react-app. Sandpit manages inputs like touches, taps, and clicks, and it handles touch event-handling for multitouch on mobile devices. Other capabilities include making it easy to drop in settings with an API for specifying ranges, types, and defaults, and helpers that cover math, color, and vector manipulation. Settings are stored in the query string, enabling copying and pasting without touching any code, and developers can import their own work in canvas.

Sandpit supports modern browsers, including Microsoft’s Internet Explorer 11 and Edge. The babel-polyfill is used when compiling for ECMAScript 5. The developers of Sandpit are encouraging community contributions and have provided usage examples.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author