Adam Stacoviak changelog.com/posts

node-o3-canvas: HTML5 Canvas API for NodeJS

This isn’t the first time we’ve featured the work of our friends over at Ajax.org. In the past we mentioned o3 and Cloud9 and even had them on the podcast, see episode #16.

Their project, node-o3-canvas, is an HTML5 Canvas implementation for NodeJS based on LibAGG and Freetype. It’s implemented using their previously mentioned O3 component system. The goal with node-o3-canvas is not only to create a Canvas-spec type API, but also to extend it to provide easy image resizing, and image processing API’s for server side image processing needs.

Ajax.org makes use of node-o3-canvas as a way to render Canvas charts server-side to allow emailing or save-as-picture.

Example usage

How to use:

var createContext = require('path/to/node-o3-canvas/lib/o3-canvas');

Here’s a simple example usage:

var ctx = createContext(300,300, "argb");
ctx.clearRect(0,0,300,300);
ctx.fillStyle = "rgb(200,0,0)";
ctx.fillRect (10, 10, 55, 50);

var buf = ctx.pngBuffer();
console.log(buf.toBase64());

[Source on GitHub] [Readme] [Blog Post]


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00