• josh.earth
  • ← All projects

    PureImage

    A pure JS & TS implementation of the HTML Canvas 2D API

    Personal · 2015

    PureImage is a 100% JavaScript implementation of the HTML Canvas 2D drawing api that I started over a decade ago.

    It can render into a memory buffer, read and write image files, and load truetype fonts. Because it is headless and 100% JavaScript (now TypeScript) with no native dependencies, PureImage is useful for server-side graphics, command-line tools, and image generation in environments where native graphics libraries are difficult to install, such as older Raspberry Pi ARM architectures and cloud services like Azure.

    Interestingly, even though I originally built it for headless environments like NodeJS, some people actually run it in the browser because it can be used in service workers that don't have access to the native Canvas api.

    Generated graphics

    These procedural graphics were rendered to PNG by experiments in the archived project, using PureImage for the drawing and image output.

    Procedural color bands and noise rendered with PureImage

    A color-band and noise experiment rendered to a 600 × 600 PNG.

    A green and blue shaded sphere rendered with PureImage

    A shaded sphere with procedural green and blue color variation.

    A grayscale marble texture rendered with PureImage

    A grayscale marble pattern generated with layered noise.