JSPM

canvas-flatten

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9057
  • Score
    100M100P100Q127390F
  • License MIT

Flatten canvas image data with transparency on a solid background

Package Exports

  • canvas-flatten

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (canvas-flatten) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

canvas-flatten

Flatten canvas image data with transparency on a solid background

Usage

First, install the package using npm:

npm install canvas-flatten --save

Then, require the package and use it like so:

let Flatten = require('canvas-flatten');

// Assume we have an existing canvas element with a 2D context
// Retrieve the image data of the canvas
let image = context.getImageData(0, 0, canvas.width, canvas.height);

// Flatten the transparency on a white background
image = Flatten.flatten(image, [ 0xff, 0xff, 0xff ]);

// Place the image data back on the canvas
context.putImageData(image, 0, 0);

License

MIT