# image-mask

> Dynamically add transparent mask to image.

Latest version **0.0.1** (published 2016-08-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install image-mask
pnpm add image-mask
yarn add image-mask
bun add image-mask
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2016-08-05 |
| First published | 2016-08-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Bartosz Krawczyk |
| Maintainers | bartoszkrawczyk |

## Links

- npm: https://www.npmjs.com/package/image-mask
- Repository: https://github.com/bartoszkrawczyk2/image-mask
- Homepage: https://github.com/bartoszkrawczyk2/image-mask#readme
- Issues: https://github.com/bartoszkrawczyk2/image-mask/issues
- npm.io page: https://npm.io/package/image-mask

## Dependencies (1)

- [blueimp-canvas-to-blob](https://npm.io/package/blueimp-canvas-to-blob.md) ^3.3.0

## Recent versions

- 0.0.1 (latest) — 2016-08-05

## README

# image-mask
Dynamically add transparent mask to image.

## Install

`npm install image-mask --save`

## API

* `new ImageMask(source, pixels: bool)` - create new masked image (returns canvas element).
  * `source`: Img element, image object or canvas.
  * `pixels`: Use pixel coordinates instead of percentage. Default: **false**
* `.mask(array)` - apply mask.
* `.getImg(callback)` - returns img element.

## Usage
Example usage:
```js
import ImageMask from 'image-mask';
let maskImage = new ImageMask(document.getElementById('example-image'));
document.body.appendChild(maskImage);

maskImage.mask([
    [0, .95],           // start point
    [.8, .95, 1, .7],   // quadratic curve
    [1, 1],             // line
    [0, 1],             // line
]);

// 2 points = line
// 4 points = quadratic curve
// 6 points = bezier curve
```
Result will be:

![output](http://projects.bartoszkrawczyk.com/im1.png)

`.mask` also returns canvas, so you can append it like this:

```js
element.appendChild(maskImage.mask([
    [.2, .5],
    [.43, .5],
    [.5, .3],
    [.57, .5],
    [.8, .5],
    [.6, .6],
    [.7, .8],
    [.5, .68],
    [.3, .8],
    [.4, .6]
]));
```

Result will be:

![output](http://projects.bartoszkrawczyk.com/im2.png)

## License

MIT

---
_Source: https://npm.io/package/image-mask · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
