trim-canvas

0.1.2 • Public • Published

trim-canvas

NPM

A tiny (< 100 LoC) library for trimming whitespace from a canvas element with no dependencies.

Installation

npm i -S trim-canvas

Usage

import trimCanvas from 'trim-canvas'

let canvas = document.createElement('canvas')

// do some drawing on it ...

trimCanvas(canvas)
// now the whitespace has been trimmed

If you don't want to mess with your existing canvas, then simply clone the canvas element beforehand.

trim-canvas returns the canvas element for easy chaining.

Credits

Credits go to @efc for writing a quick version of this in this issue and to the original StackOverflow Answer that was credited in that issue.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.2
    241,728
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.2
    241,728
  • 0.1.1
    20
  • 0.1.0
    2

Package Sidebar

Install

npm i trim-canvas

Weekly Downloads

218,468

Version

0.1.2

License

Apache-2.0

Last publish

Collaborators

  • agilgur5