# Canvacard

### Classes

[Canvacard](#Canvacard)

### Functions

[trigger(image)](#trigger) ⇒ `Promise.<Buffer>`

Trigger an image

[invert(image)](#invert) ⇒ `Promise.<Buffer>`

Invert an image

[sepia(image)](#sepia) ⇒ `Promise.<Buffer>`

Sepia an image

[greyscale(image)](#greyscale) ⇒ `Promise.<Buffer>`

Greyscale an image

[brightness(image, amount)](#brightness) ⇒ `Promise.<Buffer>`

Edit the brightness of the image

[darkness(image, amount)](#darkness) ⇒ `Promise.<Buffer>`

Darken an image

[threshold(image, amount)](#threshold) ⇒ `Promise.<Buffer>`[convolute(image, matrix, opaque)](#convolute) ⇒ `Promise.<Buffer>`

Convolute an image

[pixelate(image, pixels)](#pixelate) ⇒ `Promise.<Buffer>`

Pixelate an image

[sharpen(image, lvl)](#sharpen) ⇒ `Promise.<Buffer>`

Sharpen an image

[burn(image, lvl)](#burn) ⇒ `Promise.<Buffer>`

Burn an image

[circle(image)](#circle) ⇒ `Promise.<Buffer>`

Circle an image

[fuse(image1, image2)](#fuse) ⇒ `Promise.<Buffer>`

Fuse two images

[resize(image, width, height)](#resize) ⇒ `Promise.<Buffer>`

Resize an image

[kiss(image1, image2)](#kiss) ⇒ `Promise.<Buffer>`

Kiss someone ( ͡° ͜ʖ ͡°)

[spank(image1, image2)](#spank) ⇒ `Promise.<Buffer>`

To spank someone ( ͡° ͜ʖ ͡°)

[slap(image1, image2)](#slap) ⇒ `Promise.<Buffer>`

Slap someone ( ͡° ͜ʖ ͡°)

[facepalm(image)](#facepalm) ⇒ `Promise.<Buffer>`

Facepalm someone

[colorfy(image, color)](#colorfy) ⇒ `Promise.<Buffer>`

Colorfy an image

[distracted(image1, image2, image3)](#distracted) ⇒ `Promise.<Buffer>`

Distract someone

[jail(image, greyscale)](#jail) ⇒ `Promise.<Buffer>`

Create a jail image

[bed(image1, image2)](#bed) ⇒ `Promise.<Buffer>`

Create a bed image

[delete(image, dark)](#delete) ⇒ `Promise.<Buffer>`

Create a deleted image

[gradient(colorFrom, colorTo, width, height)](#gradient) ⇒ `Promise.<Buffer>`

Create a gradient image

[quote(options, \[font\])](#quote) ⇒ `Promise.<Buffer>`

Create a fake quote image

[phub(options, \[font\])](#phub) ⇒ `Promise.<Buffer>`

PornHub Comment

[wanted(image)](#wanted) ⇒ `Promise.<Buffer>`

Create a "wanted" image

[wasted(image)](#wasted) ⇒ `Promise.<Buffer>`

Create a "wasted" image

[youtube(ops)](#youtube) ⇒ `Promise.<Buffer>`

Create a YouTube comment image

[write(data, name)](#write) ⇒ `void`

Writes data as a file

[reply(options)](#reply) ⇒ `Promise.<Buffer>`

Discord Reply Clone

### Canvacard

**Kind**: global class<br>

#### new Canvacard()

Image generator

**Example**

```js
const canvacard = require("canvacard");
canvacard.Canvas.trigger("./image.png")
  .then(triggered => {
    canvacard.write(triggered, "triggered.gif");
  })
  .catch(console.error);
```

### trigger(image) ⇒ `Promise.<Buffer>`

Trigger an image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Triggered image\
**Throws**:

* `APIError` If image is not provided

| Param | Type                 | Description      |
| ----- | -------------------- | ---------------- |
| image | `string` \| `Buffer` | Image to trigger |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.trigger("./image.png")
    .then(triggered => {
      canvacard.write(triggered, "triggered.gif");
    })
    .catch(console.error);
```

### invert(image) ⇒ `Promise.<Buffer>`

Invert an image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Inverted image\
**Throws**:

* `APIError` If image is not provided

| Param | Type                 | Description     |
| ----- | -------------------- | --------------- |
| image | `string` \| `Buffer` | Image to invert |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.invert("./image.png")
    .then(inverted => {
      canvacard.write(inverted, "inverted.png");
    })
    .catch(console.error);
```

### sepia(image) ⇒ `Promise.<Buffer>`

Sepia an image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Sepia image\
**Throws**:

* `APIError` If image is not provided

| Param | Type                 | Description    |
| ----- | -------------------- | -------------- |
| image | `string` \| `Buffer` | Image to sepia |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.sepia("./image.png")
    .then(sepia => {
      canvacard.write(sepia, "sepia.png");
    })
    .catch(console.error);
```

### greyscale(image) ⇒ `Promise.<Buffer>`

Greyscale an image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Greyscale image\
**Throws**:

* `APIError` If image is not provided

| Param | Type                 | Description        |
| ----- | -------------------- | ------------------ |
| image | `string` \| `Buffer` | Image to greyscale |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.greyscale("./image.png")
    .then(greyscale => {
      canvacard.write(greyscale, "greyscale.png");
    })
    .catch(console.error);
```

### brightness(image, amount) ⇒ `Promise.<Buffer>`

Edit the brightness of the image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Brightened image\
**Throws**:

* `APIError` If image is not provided o la cantidad no es un número

| Param  | Type                 | Description          |
| ------ | -------------------- | -------------------- |
| image  | `string` \| `Buffer` | Image to brighten    |
| amount | `number`             | Amount of brightness |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.brightness("./image.png", 50)
    .then(brightened => {
      canvacard.write(brightened, "brightened.png");
    })
    .catch(console.error);
```

### darkness(image, amount) ⇒ `Promise.<Buffer>`

Darken an image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Darkened image\
**Throws**:

* `APIError` If image is not provided o la cantidad no es un número

| Param  | Type                 | Description        |
| ------ | -------------------- | ------------------ |
| image  | `string` \| `Buffer` | Image to darken    |
| amount | `number`             | Amount of darkness |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.darkness("./image.png", 50)
    .then(darkened => {
      canvacard.write(darkened, "darkened.png");
    })
    .catch(console.error);
```

### threshold(image, amount) ⇒ `Promise.<Buffer>`

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Thresholded image\
**Throws**:

* `APIError` If image is not provided o la cantidad no es un número

**Descrioption**: Threshold an image

| Param  | Type                 | Description         |
| ------ | -------------------- | ------------------- |
| image  | `string` \| `Buffer` | Image to threshold  |
| amount | `number`             | Amount of threshold |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.threshold("./image.png", 128)
    .then(thresholded => {
      canvacard.write(thresholded, "thresholded.png");
    })
    .catch(console.error);
```

### convolute(image, matrix, opaque) ⇒ `Promise.<Buffer>`

Convolute an image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Convoluted image\
**Throws**:

* `APIError` If image is not provided o la matriz no es un Array

| Param  | Type                 | Description                   |
| ------ | -------------------- | ----------------------------- |
| image  | `string` \| `Buffer` | Image to convolute            |
| matrix | `Array.<number>`     | Convolution matrix            |
| opaque | `boolean`            | If the image should be opaque |

**Example**

```js
    const canvacard = require("canvacard");
    const matrix = [0, -1, 0, -1, 5, -1, 0, -1, 0];  // Ejemplo de matriz de convolución
    canvacard.Canvas.convolute("./image.png", matrix, true)
    .then(convoluted => {
      canvacard.write(convoluted, "convoluted.png");
    })
    .catch(console.error);
```

### pixelate(image, pixels) ⇒ `Promise.<Buffer>`

Pixelate an image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Pixelated image\
**Throws**:

* `APIError` If image is not provided o los píxeles no son un número

| Param  | Type                 | Description       |
| ------ | -------------------- | ----------------- |
| image  | `string` \| `Buffer` | Image to pixelate |
| pixels | `number`             | Amount of pixels  |

**Example**

````js
    const canvacard = require("canvacard");
    canvacard.Canvas.pixelate("./image.png", 5)
    .then(pixelated => {
      canvacard.write(pixelated, "pixelated.png");
    })
    .catch(console.error);
<a name="sharpen"></a>

## sharpen(image, lvl) ⇒ <code>Promise.&lt;Buffer&gt;</code>
Sharpen an image

**Kind**: global function  
**Returns**: <code>Promise.&lt;Buffer&gt;</code> - Sharpened image  
**Throws**:

- <code>APIError</code> If image is not provided o el nivel no es un número


| Param | Type | Description |
| --- | --- | --- |
| image | <code>string</code> \| <code>Buffer</code> | Image to sharpen |
| lvl | <code>number</code> | Level of sharpening |

**Example**  
```js
    const canvacard = require("canvacard");
    canvacard.Canvas.sharpen("./image.png", 1)
    .then(sharpened => {
      canvacard.write(sharpened, "sharpened.png");
    })
    .catch(console.error);
````

### burn(image, lvl) ⇒ `Promise.<Buffer>`

Burn an image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Burned image\
**Throws**:

* `APIError` If image is not provided o el nivel no es un número

| Param | Type                 | Description      |
| ----- | -------------------- | ---------------- |
| image | `string` \| `Buffer` | Image to burn    |
| lvl   | `number`             | Level of burning |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.burn("./image.png", 1)
    .then(burned => {
      canvacard.write(burned, "burned.png");
    })
    .catch(console.error);
```

### circle(image) ⇒ `Promise.<Buffer>`

Circle an image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Circled image\
**Throws**:

* `APIError` If image is not provided

| Param | Type                 | Description     |
| ----- | -------------------- | --------------- |
| image | `string` \| `Buffer` | Image to circle |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.circle("./image.png")
    .then(circled => {
      canvacard.write(circled, "circled.png");
    })
    .catch(console.error);
```

### fuse(image1, image2) ⇒ `Promise.<Buffer>`

Fuse two images

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Fused image\
**Throws**:

* `APIError` If image is not provided

| Param  | Type                 | Description  |
| ------ | -------------------- | ------------ |
| image1 | `string` \| `Buffer` | First image  |
| image2 | `string` \| `Buffer` | Second image |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.fuse("./image1.png", "./image2.png")
      .then(fused => {
      canvacard.write(fused, "fused.png");
    })
    .catch(console.error);
```

### resize(image, width, height) ⇒ `Promise.<Buffer>`

Resize an image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Resized image\
**Throws**:

* `APIError` If image is not provided

| Param  | Type                 | Description     |
| ------ | -------------------- | --------------- |
| image  | `string` \| `Buffer` | Image to resize |
| width  | `number`             | Width           |
| height | `number`             | Height          |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.resize("./image.png", 500, 500)
    .then(resized => {
      canvacard.write(resized, "resized.png");
    })
    .catch(console.error);
```

### kiss(image1, image2) ⇒ `Promise.<Buffer>`

Kiss someone ( ͡° ͜ʖ ͡°)

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Imagen de beso\
**Throws**:

* `APIError` If image is not provided

| Param  | Type                 | Description  |
| ------ | -------------------- | ------------ |
| image1 | `string` \| `Buffer` | First image  |
| image2 | `string` \| `Buffer` | Second image |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.kiss("./image1.png", "./image2.png")
    .then(kissed => {
      canvacard.write(kissed, "kissed.png");
    })
    .catch(console.error);
```

### spank(image1, image2) ⇒ `Promise.<Buffer>`

To spank someone ( ͡° ͜ʖ ͡°)

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Image of spank\
**Throws**:

* `APIError` If image is not provided

| Param  | Type                 | Description  |
| ------ | -------------------- | ------------ |
| image1 | `string` \| `Buffer` | First image  |
| image2 | `string` \| `Buffer` | Second image |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.spank("./image1.png", "./image2.png")
    .then(spanked => {
      canvacard.write(spanked, "spanked.png");
    })
    .catch(console.error);
```

### slap(image1, image2) ⇒ `Promise.<Buffer>`

Slap someone ( ͡° ͜ʖ ͡°)

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Image of slap\
**Throws**:

* `APIError` If image is not provided

| Param  | Type                 | Description  |
| ------ | -------------------- | ------------ |
| image1 | `string` \| `Buffer` | First image  |
| image2 | `string` \| `Buffer` | Second image |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.slap("./image1.png", "./image2.png")
    .then(slap => {
      canvacard.write(slap, "slap.png");
    })
    .catch(console.error);
```

### facepalm(image) ⇒ `Promise.<Buffer>`

Facepalm someone

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Image of facepalm\
**Throws**:

* `APIError` If image is not provided

| Param | Type                 | Description       |
| ----- | -------------------- | ----------------- |
| image | `string` \| `Buffer` | Image to facepalm |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.facepalm("./image.png")
    .then(facepalm => {
      canvacard.write(facepalm, "facepalm.png");
    })
    .catch(console.error);
```

### colorfy(image, color) ⇒ `Promise.<Buffer>`

Colorfy an image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Colorfied image\
**Throws**:

* `APIError` If image is not provided

| Param | Type                 | Description                       |
| ----- | -------------------- | --------------------------------- |
| image | `string` \| `Buffer` | Image to colorfy                  |
| color | `string`             | Color to apply to the image (hex) |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.colorfy("./image.png", "#FF0000")
    .then(colorfy => {
      canvacard.write(colorfy, "colorfy.png");
    })
    .catch(console.error);
```

### distracted(image1, image2, image3) ⇒ `Promise.<Buffer>`

Distract someone

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Distracted image\
**Throws**:

* `APIError` If image is not provided

| Param  | Type                 | Description                         |
| ------ | -------------------- | ----------------------------------- |
| image1 | `string` \| `Buffer` | Face for the girl in red.           |
| image2 | `string` \| `Buffer` | Face for the boy.                   |
| image3 | `string` \| `Buffer` | Face for the other girl \[optional] |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.distracted("./image1.png", "./image2.png", "./image3.png")
    .then(distracted => {
      canvacard.write(distracted, "distracted.png");
    })
    .catch(console.error);
```

### jail(image, greyscale) ⇒ `Promise.<Buffer>`

Create a jail image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Jailed image\
**Throws**:

* `APIError` If image is not provided

| Param     | Type                 | Description                      |
| --------- | -------------------- | -------------------------------- |
| image     | `string` \| `Buffer` | Image to jail                    |
| greyscale | `boolean`            | If the image should be greyscale |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.jail("./image.png")
    .then(jail => {
      canvacard.write(jail, "jail.png");
    })
    .catch(console.error);
```

### bed(image1, image2) ⇒ `Promise.<Buffer>`

Create a bed image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Imagen de cama\
**Throws**:

* `APIError` If image is not provided

| Param  | Type                 | Description  |
| ------ | -------------------- | ------------ |
| image1 | `string` \| `Buffer` | First image  |
| image2 | `string` \| `Buffer` | Second image |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.bed("./image1.png", "./image2.png")
    .then(bed => {
      canvacard.write(bed, "bed.png");
    })
    .catch(console.error);
```

### delete(image, dark) ⇒ `Promise.<Buffer>`

Create a deleted image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Deleted image\
**Throws**:

* `APIError` If image is not provided

| Param | Type                 | Description                 |
| ----- | -------------------- | --------------------------- |
| image | `string` \| `Buffer` | Image to delete             |
| dark  | `boolean`            | If the image should be dark |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.delete("./image.png")
    .then(deleted => {
      canvacard.write(deleted, "deleted.png");
    })
    .catch(console.error);
```

### gradient(colorFrom, colorTo, width, height) ⇒ `Promise.<Buffer>`

Create a gradient image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Gradient image\
**Throws**:

* `APIError` If colorFrom or colorTo is not provided

| Param     | Type     | Description     |
| --------- | -------- | --------------- |
| colorFrom | `string` | First color     |
| colorTo   | `string` | Second color    |
| width     | `number` | Width of image  |
| height    | `number` | Height of image |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.gradient("#FF0000", "#0000FF", 500, 500)
    .then(gradient => {
      canvacard.write(gradient, "gradient.png");
    })
    .catch(console.error);
```

### quote(options, \[font]) ⇒ `Promise.<Buffer>`

Create a fake quote image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Quote image

| Param               | Type                 | Default               | Description            |
| ------------------- | -------------------- | --------------------- | ---------------------- |
| options             | `object`             |                       | Options                |
| \[options.image]    | `Buffer` \| `string` |                       | Image                  |
| \[options.message]  | `string`             |                       | Message                |
| \[options.username] | `string`             |                       | Username               |
| \[options.color]    | `string`             |                       | Color                  |
| \[font]             | `string`             | `"&quot;Arial&quot;"` | Text font for the card |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.quote({ image: "./image.png", message: "This is amazing!", username: "Clyde", color: "#FFFFFF" })
    .then(quote => {
      canvacard.write(quote, "quote.png");
    })
    .catch(console.error);
```

### phub(options, \[font]) ⇒ `Promise.<Buffer>`

PornHub Comment

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - PornHub Comment image\
**Throws**:

* `APIError` If username, message or image is not provided

| Param               | Type                 | Default               | Description        |
| ------------------- | -------------------- | --------------------- | ------------------ |
| options             | `Object`             |                       | Options            |
| \[options.username] | `String`             |                       | Username           |
| \[options.message]  | `String`             |                       | Message            |
| \[options.image]    | `String` \| `Buffer` |                       | Image              |
| \[font]             | `string`             | `"&quot;Arial&quot;"` | Text font for card |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.phub({ username: "Clyde", message: "This is amazing!", image: "./image.png" })
    .then(phub => {
      canvacard.write(phub, "phub.png");
    })
    .catch(console.error);
```

### wanted(image) ⇒ `Promise.<Buffer>`

Create a "wanted" image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Wanted image\
**Throws**:

* `APIError` If image is not provided

| Param | Type                 | Description     |
| ----- | -------------------- | --------------- |
| image | `string` \| `Buffer` | Image to wanted |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.wanted("./image.png")
    .then(wanted => {
      canvacard.write(wanted, "wanted.png");
    })
    .catch(console.error);
```

### wasted(image) ⇒ `Promise.<Buffer>`

Create a "wasted" image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Wasted image\
**Throws**:

* `APIError` If image is not provided

| Param | Type                 | Description     |
| ----- | -------------------- | --------------- |
| image | `string` \| `Buffer` | Image to wasted |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.wasted("./image.png")
    .then(wasted => {
      canvacard.write(wasted, "wasted.png");
    })
    .catch(console.error);
```

### youtube(ops) ⇒ `Promise.<Buffer>`

Create a YouTube comment image

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - YouTube comment image\
**Throws**:

* `APIError` If username, content or avatar is not provided

| Param           | Type                 | Default | Description |
| --------------- | -------------------- | ------- | ----------- |
| ops             | `object`             |         | Options     |
| \[ops.username] | `string`             |         | Username    |
| \[ops.content]  | `string`             |         | Content     |
| \[ops.avatar]   | `string` \| `Buffer` |         | Avatar      |
| \[ops.dark]     | `boolean`            | `false` | Dark mode   |

**Example**

```js
    const canvacard = require("canvacard");
    canvacard.Canvas.youtube({ username: "Clyde", content: "This is amazing!", avatar: "./image.png" })
    .then(youtube => {
      canvacard.write(youtube, "youtube.png");
    })
    .catch(console.error);
```

### write(data, name) ⇒ `void`

Writes data as a file

**Kind**: global function

| Param | Type     | Description   |
| ----- | -------- | ------------- |
| data  | `Buffer` | data to write |
| name  | `string` | file name     |

### reply(options) ⇒ `Promise.<Buffer>`

Discord Reply Clone

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Reply image\
**Throws**:

* `APIError` If the avatar, username or message is not provided

| Param                | Type                 | Description                                   |
| -------------------- | -------------------- | --------------------------------------------- |
| options              | `object`             | Options                                       |
| \[options.avatar1]   | `string` \| `Buffer` | Avatar of the person who responded            |
| \[options.avatar2]   | `string` \| `Buffer` | Avatar of the other person                    |
| \[options.user1]     | `string`             | Username of the person who responded          |
| \[options.user2]     | `string`             | Username of the other person                  |
| \[options.hex1]      | `string`             | Hexadecimal color of the person who responded |
| \[options.hex2]      | `string`             | Hexadecimal color of the other person         |
| \[options.mainText]  | `string`             | Message of the person who responded           |
| \[options.replyText] | `string`             | Message of the other person                   |

**Example**

```js
const img = "https://cdn.discordapp.com/embed/avatars/0.png";
  const img2 = "https://cdn.discordapp.com/embed/avatars/4.png";
  canvacard.Canvas.reply({
    avatar1: img,
    avatar2: img2,
    user1: "Maximus",
    user2: "SrGobi",
    hex1: "#FF3300",
    hex2: "#7289da",
    mainText: "kok",
    replyText: "Pog"
   })
  .then(img => canvacard.write(img, "reply.png"));
```
