# Welcome

## [![Typing SVG](https://readme-typing-svg.herokuapp.com?font=Fira+Code\&weight=500\&size=40\&pause=1000\&color=5865F2\&multiline=true\&random=false\&width=435\&lines=Canvacard)](/)

[![](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/banner_Canvacard.png)](https://github.com/SrGobi/canvacard)

[![](https://nodei.co/npm/canvacard.png)](https://nodei.co/npm/canvacard/)

![](https://img.shields.io/npm/v/canvacard?style=for-the-badge) ![](https://img.shields.io/npm/dm/canvacard?style=for-the-badge) ![size](https://img.shields.io/bundlephobia/minzip/canvacard?label=size\&style=for-the-badge) ![](https://img.shields.io/npm/l/hercai?style=for-the-badge) ![](https://img.shields.io/npm/dt/canvacard?style=for-the-badge) [![Discord](https://img.shields.io/badge/Support-Click%20here-7289d9?style=for-the-badge\&logo=discord)](https://discord.gg/cqrN3Eg)

### [![Typing SVG](https://readme-typing-svg.herokuapp.com?font=Fira+Code\&weight=500\&pause=1000\&color=F20000\&random=false\&width=435\&lines=%E2%9D%94How+To+Install%3F)](/)

```console
npm i canvacard
```

## [![Typing SVG](https://readme-typing-svg.herokuapp.com?font=Fira+Code\&weight=500\&pause=1000&\&color=00EDFF\&random=false\&width=435\&lines=%F0%9F%8E%AF+Describing)](/)

For **CommonJS**

```javascript
const canvacard = require("canvacard");
```

For **EsModule** And **TypeScript**

```typescript
import canvacard from "canvacard";
```

## ✨Features

* 🪟 **Open source and no privacy concerns, fully transparent** - Canvacard is open source and free. You can contribute and you don't have to worry about privacy.
* 💪 **Easy to use** - Canvacard offers an intuitive and easy API to efficiently generate images, perfect for developers of all levels.
* 🚀 **Speed ​​and optimization** - The libraries it uses are highly optimized, offering exceptional performance when creating images.
* 🔒 **Typescript support** - Canvacard is built in Typescript, which allows for the use of type definitions and improves the developer experience.
* 🎨 **More than 50 customization options** - You have access to many tools to completely adjust and modify your images or cards.
* 🖼️ **Creating interactive and personalized cards** - Canvacard is perfect for creating custom cards for Discord, adding graphics, banners, badges, and more.
* 🛠️ **Object Oriented Design** - Canvacard is built with an object-oriented programming approach, making it easy to reuse and create complex cards.
* 🤓 **Ideal for beginners** - The API and documentation are simple, making it accessible even to those with little experience handling images.
* 🔡 **Register fonts** - Not only can you use the fonts from your machine, if you also use it for a server you can register the fonts you want!

For **CommonJS**

```javascript
const { registerFont } = require("canvacard");

// Path to source file and alias
const fontPath = "./path/to/font.ttf";
const fontName = "CustomFont";

registerFont(fontPath, fontName);

console.log(`Fuente ${fontName} registrada exitosamente.`);
```

For **EsModule** And **TypeScript**

```typescript
import { registerFont } from "canvacard";

// Define types for clarity
const fontPath: string = "./path/to/font.ttf";
const fontName: string = "CustomFont";

registerFont(fontPath, fontName);

console.log(`Fuente ${fontName} registrada exitosamente.`);
```

## 📦Examples

### [Rank Card](https://canvacard.srgobi.com/classes/rank)

```js
const { AttachmentBuilder } = require("discord.js");
const canvacard = require("canvacard");
const userData = getDataSomehow(); // Simulates obtaining user data

const rank = new canvacard.Rank()
  .setAvatar(userData.avatarURL, userData.avatar_decoration_data.asset, false)
  .setBanner(userData.bannerURL, true)
  .setBadges(userData.flags, userData.bot, true)
  .setBorder(["#22274a", "#001eff"], "vertical")
  .setCurrentXP(userData.xp)
  .setRequiredXP(userData.requiredXP)
  .setRank(1, "RANK", true)
  .setLevel(20, "LEVEL")
  .setStatus("online")
  .setProgressBar(["#14C49E", "#FF0000"], "GRADIENT", true)
  .setUsername(userData.username, userData.discriminator, "#FFFFFF")
  .setCreatedTimestamp(userData.createdTimestamp);

rank.build("Cascadia Code PL")
  .then(data => {
    // Use AttachmentBuilder to upload the file
    const attachment = new AttachmentBuilder(data, { name: "RankCard.png" });
    message.channel.send({ content: "Here is your rank card:", files: [attachment] });
  })
  .catch(err => console.error("Error creating rank card:", err));
```

<details>

<summary>PREVIEW</summary>

\
![Rank Card Preview 1](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/rank_1.png) ![Rank Card Preview 2](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/rank_2.png) ![Rank Card Preview 3](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/rank_3.png) ![Rank Card Preview 4](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/rank_4.png) ![Rank Card Preview 5](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/rank_5.png)

</details>

### [Welcome / Leave Card](https://canvacard.srgobi.com/classes/welcomeleave)

```js
const canvacard = require("canvacard");
const img = "https://cdn.discordapp.com/embed/avatars/0.png";
const background = "https://i.imgur.com/5O7xmVe.png";

const welcomer = new canvacard.WelcomeLeave()
  .setAvatar(img)
  .setBackground('COLOR', '#000000')
  .setTitulo("Card Title 👋", '#FFFFFF')
  .setSubtitulo("Card Caption 👋", '#FFFFFF')
  .setOpacityOverlay(1)
  .setColorCircle('#FFFFFF')
  .setColorOverlay('#5865F2')
  .setTypeOverlay('ROUNDED');

welcomer.build("Cascadia Code PL, Noto Color Emoji")
  .then(data => {
    // Use AttachmentBuilder to upload the file
    const attachment = new AttachmentBuilder(data, { name: "WelcomeCard.png" });
    message.channel.send({ content: "Here is your welcome card:", files: [attachment] });
  })
  .catch(err => console.error("Error creating welcome card:", err));
```

<details>

<summary>PREVIEW</summary>

\
![Welcome Card Preview 1](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/welcome_1.png) ![Welcome Card Preview 2](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/welcome_2.png) ![Welcome Card Preview 3](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/welcome_3.png) ![Welcome Card Preview 4](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/welcome_4.png)

</details>

### [Spotify Card](https://canvacard.srgobi.com/classes/spotify)

```js
const canvacard = require("canvacard");

const spotify = new canvacard.Spotify()
  .setAuthor("SAIKO")
  .setAlbum("SAKURA 👋")
  .setStartTimestamp(Date.now() - 10000)
  .setEndTimestamp(Date.now() + 50000)
  .setImage("https://i.scdn.co/image/ab67616d00001e02e346fc6f767ca2ac8365fe60")
  .setTitle("YO LO SOÑÉ");

spotify.build("Cascadia Code PL, Noto Color Emoji")
  .then(data => {
    // Use AttachmentBuilder to upload the file
    const attachment = new AttachmentBuilder(data, { name: "SpotifyCard.png" });
    message.channel.send({ content: "Here is your spotify card:", files: [attachment] });
  })
  .catch(err => console.error("Error creating spotify card:", err));
```

![Spotify Card Preview](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/spotify.png)

### [Canvacard Circle](https://canvacard.srgobi.com/classes/canvacard)

```js
const canvacard = require("canvacard");

canvacard.Canvas.circle(data.avatarURL)
.then(data => {
  canvacard.write(data, "circle.png");
})
.catch(console.error);
```

![Circle Preview](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/images/circle.png)

### [Otros ejemplos](https://canvacard.srgobi.com)

```js
const { Client, GatewayIntentBits, AttachmentBuilder } = require("discord.js");
const canvacard = require("canvacard");

const client = new Client({
    intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});

client.on('ready', () => {
  console.log('¡I am online!');
});

client.on('messageCreate', async (message) => {
  if (message.author.bot) return;

  if (message.content === '!triggered') {
    try {
      let avatar = message.author.displayAvatarURL({ dynamic: false, format: 'png' });
      let image = await canvacard.Canvas.trigger(avatar);
      // Enviar el archivo generado usando AttachmentBuilder
      let attachment = new AttachmentBuilder(image, { name: 'triggered.gif' });
      await message.channel.send({ content: 'Here is your "triggered" image!', files: [attachment] });
    } catch (err) {
      console.error('Error generating image triggered:', err);
    }
  }
});

client.login('Your_Bot_Token_Here');
```

<details>

<summary>PREVIEW</summary>

\
![Fortnite Shop](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/fortnite_shop.png)

</details>


# Classes


# Welcome / Leave

### Classes

[WelcomeLeave](#WelcomeLeave)

### Functions

[setAvatar(value)](#setAvatar) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set the avatar of the card

[setTitulo(value, color)](#setTitulo) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set the title of the card

[setSubtitulo(value, color)](#setSubtitulo) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set the subtitle of the card

[setColorCircle(value)](#setColorCircle) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set the color of the circle

[setColorOverlay(value)](#setColorOverlay) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set the color of the overlay

[setOpacityOverlay(value)](#setOpacityOverlay) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set the opacity of the overlay

[setBackground(type, data)](#setBackground) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set background image/color of the card

[setTypeOverlay(type)](#setTypeOverlay) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set the type of overlay

[build(\[font\])](#build) ⇒ `Promise.<Buffer>`

Build the card

### WelcomeLeave

**Kind**: global class<br>

#### new WelcomeLeave()

Welcome or Leave card creator

<details>

<summary>PREVIEW</summary>

\
![Welcome Card Preview 1](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/welcome_1.png) ![Welcome Card Preview 2](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/welcome_2.png) ![Welcome Card Preview 3](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/welcome_3.png)

</details>

**Example**

```js
const welcome = new canvacard.WelcomeLeave()
  .setAvatar(data.avatarURL)
  .setBackground('COLOR', '#000000')
  .setTitulo("Titulo de la Tarjeta👋", '#FFFFFF')
  .setSubtitulo("Subtitulo de la Tarjeta 👋", '#FFFFFF')
  .setOpacityOverlay(1)
  .setColorCircle('#FFFFFF')
  .setColorOverlay('#5865F2')
  .setTypeOverlay('ROUNDED');
const welcomeImage = await welcome.build("Suravaram");
canvacard.write(welcomeImage, "./welcomer.png");
```

### setAvatar(value) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set the avatar of the card

**Kind**: global function\
**Returns**: [`WelcomeLeave`](#WelcomeLeave) - The current instance of WelcomeLeave\
**Throws**:

* `APIError` Missing field: avatar

| Param | Type                 | Description          |
| ----- | -------------------- | -------------------- |
| value | `string` \| `Buffer` | Avatar URL or Buffer |

### setTitulo(value, color) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set the title of the card

**Kind**: global function\
**Returns**: [`WelcomeLeave`](#WelcomeLeave) - The current instance of WelcomeLeave\
**Throws**:

* `APIError` The title must be a string

| Param | Type     | Description                |
| ----- | -------- | -------------------------- |
| value | `string` | Title value                |
| color | `string` | HTML5 color code "#000000" |

### setSubtitulo(value, color) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set the subtitle of the card

**Kind**: global function\
**Returns**: [`WelcomeLeave`](#WelcomeLeave) - The current instance of WelcomeLeave\
**Throws**:

* `APIError` The subtitle must be a string

| Param | Type     | Description                |
| ----- | -------- | -------------------------- |
| value | `string` | Subtitle value             |
| color | `string` | HTML5 color code "#000000" |

### setColorCircle(value) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set the color of the circle

**Kind**: global function\
**Returns**: [`WelcomeLeave`](#WelcomeLeave) - The current instance of WelcomeLeave\
**Throws**:

* `APIError` The color must be a string

| Param | Type     | Description                |
| ----- | -------- | -------------------------- |
| value | `string` | HTML5 color code "#000000" |

### setColorOverlay(value) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set the color of the overlay

**Kind**: global function\
**Returns**: [`WelcomeLeave`](#WelcomeLeave) - The current instance of WelcomeLeave\
**Throws**:

* `APIError` The color must be a string

| Param | Type     | Description                |
| ----- | -------- | -------------------------- |
| value | `string` | HTML5 color code "#000000" |

### setOpacityOverlay(value) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set the opacity of the overlay

**Kind**: global function\
**Returns**: [`WelcomeLeave`](#WelcomeLeave) - The current instance of WelcomeLeave\
**Throws**:

* `APIError` The opacity must be a number

| Param | Type     | Description            |
| ----- | -------- | ---------------------- |
| value | `number` | Opacity value (0 to 1) |

### setBackground(type, data) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set background image/color of the card

**Kind**: global function\
**Returns**: [`WelcomeLeave`](#WelcomeLeave) - The current instance of WelcomeLeave\
**Throws**:

* `APIError` Missing field: data

| Param | Type                   | Description                  |
| ----- | ---------------------- | ---------------------------- |
| type  | `"COLOR"` \| `"IMAGE"` | Type of background           |
| data  | `string`               | Image URL or HTML color code |

### setTypeOverlay(type) ⇒ [`WelcomeLeave`](#WelcomeLeave)

Set the type of overlay

**Kind**: global function\
**Returns**: [`WelcomeLeave`](#WelcomeLeave) - The current instance of WelcomeLeave\
**Throws**:

* `APIError` Missing field: type

| Param | Type                         | Description     |
| ----- | ---------------------------- | --------------- |
| type  | `"RECTANGLE"` \| `"ROUNDED"` | Type of overlay |

### build(\[font]) ⇒ `Promise.<Buffer>`

Build the card

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Card image in buffer format\
**Throws**:

* `APIError` Error loading background image

| Param   | Type     | Default   | Description             |
| ------- | -------- | --------- | ----------------------- |
| \[font] | `string` | `"Arial"` | Font to use in the card |


# FortniteShop

### Classes

[FortniteShop](#FortniteShop)

### Functions

[setToken(value)](#setToken) ⇒ [`FortniteShop`](#FortniteShop)

Set the Fortnite API token

[setText(value)](#setText) ⇒ [`FortniteShop`](#FortniteShop)

Set the text for the Fortnite Shop card

[build(\[font\])](#build) ⇒ `Promise.<Buffer>`

Build the Fortnite Shop card

### FortniteShop

**Kind**: global class<br>

#### new FortniteShop()

Fortnite Shop card creator

<details>

<summary>PREVIEW</summary>

\
![Fortnite Shop Card Preview](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/fortnite_shop.png)

</details>

To obtain a Fortnite API token, visit [fortnite-api.com](https://fortnite-api.com/)

**Example**

```js
const shop = new canvacard.FortniteShop()
  .setToken("f4a26b940ef54a9a4238cef040bd08fa9001cd6c")
  .setText("footer", "ESP CUSTOMS X FORTNITE")

const FortniteShopImage = await shop.build("Luckiest Guy");
canvacard.write(FortniteShopImage, "./fortnite_shop.png");
```

### setToken(value) ⇒ [`FortniteShop`](#FortniteShop)

Set the Fortnite API token

**Kind**: global function\
**Returns**: [`FortniteShop`](#FortniteShop) - The current instance of FortniteShop\
**Throws**:

* `APIError` If the value is not a string

| Param | Type     | Description        |
| ----- | -------- | ------------------ |
| value | `string` | Fortnite API token |

### setText(value) ⇒ [`FortniteShop`](#FortniteShop)

Set the text for the Fortnite Shop card

**Kind**: global function\
**Returns**: [`FortniteShop`](#FortniteShop) - The current instance of FortniteShop\
**Throws**:

* `APIError` If the value is not a string

| Param | Type     | Description              |
| ----- | -------- | ------------------------ |
| value | `string` | Text to set for the card |

### build(\[font]) ⇒ `Promise.<Buffer>`

Build the Fortnite Shop card

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Card image in buffer format\
**Throws**:

* `APIError` If the token is not provided

| Param   | Type     | Default               | Description              |
| ------- | -------- | --------------------- | ------------------------ |
| \[font] | `string` | `"&quot;Arial&quot;"` | Font to use for the card |


# 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"));
```


# Spotify

### Classes

[Spotify](#Spotify)

### Functions

[setProgressBar(type, color)](#setProgressBar) ⇒ [`Spotify`](#Spotify)

Set progress bar details

[setTitle(title)](#setTitle) ⇒ [`Spotify`](#Spotify)

Set title

[setImage(source)](#setImage) ⇒ [`Spotify`](#Spotify)

Establecer imagen

[setAuthor(name)](#setAuthor) ⇒ [`Spotify`](#Spotify)

Set the name of the artist

[setAlbum(name)](#setAlbum) ⇒ [`Spotify`](#Spotify)

Set the name of the album

[setStartTimestamp(time)](#setStartTimestamp) ⇒ [`Spotify`](#Spotify)

Set start timestamp

[setEndTimestamp(time)](#setEndTimestamp) ⇒ [`Spotify`](#Spotify)

Set end timestamp

[setBackground(type, data)](#setBackground) ⇒ [`Spotify`](#Spotify)

Set background image/color of the card

[build(\[font\])](#build) ⇒ `Promise.<Buffer>`

Build the Spotify presence card

### Spotify

**Kind**: global class<br>

#### new Spotify()

Spotify card creator

<details>

<summary>PREVIEW</summary>

\
![Spotify Card Preview](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/spotify.png)

</details>

**Example**

```js
const spotify = new canvacard.Spotify()
  .setAuthor("SAIKO")
  .setAlbum("SAKURA 👋")
  .setStartTimestamp(Date.now() - 10000)
  .setEndTimestamp(Date.now() + 50000)
  .setImage("https://i.scdn.co/image/ab67616d00001e02e346fc6f767ca2ac8365fe60")
  .setTitle("YO LO SOÑÉ");
const spotifyImage = await spotify.build("Cascadia Code PL");
canvacard.write(spotifyImage, "./spotify.png");
```

### setProgressBar(type, color) ⇒ [`Spotify`](#Spotify)

Set progress bar details

**Kind**: global function\
**Returns**: [`Spotify`](#Spotify) - The current instance of Spotify\
**Throws**:

* `APIError` Invalid progress bar type

| Param | Type                 | Description               |
| ----- | -------------------- | ------------------------- |
| type  | `"TRACK"` \| `"BAR"` | Type of progress bar      |
| color | `string`             | Color of the progress bar |

### setTitle(title) ⇒ [`Spotify`](#Spotify)

Set title

**Kind**: global function\
**Returns**: [`Spotify`](#Spotify) - The current instance of Spotify\
**Throws**:

* `APIError` Title expected but not received

| Param | Type     | Description       |
| ----- | -------- | ----------------- |
| title | `string` | Title of the song |

### setImage(source) ⇒ [`Spotify`](#Spotify)

Establecer imagen

**Kind**: global function\
**Returns**: [`Spotify`](#Spotify) - The current instance of Spotify\
**Throws**:

* `APIError` Image source expected but not received

| Param  | Type                                   | Description      |
| ------ | -------------------------------------- | ---------------- |
| source | `string` \| `Buffer` \| `Canvas.Image` | Fuente de imagen |

### setAuthor(name) ⇒ [`Spotify`](#Spotify)

Set the name of the artist

**Kind**: global function\
**Returns**: [`Spotify`](#Spotify) - The current instance of Spotify\
**Throws**:

* `APIError` Artist name expected but not received

| Param | Type     | Description        |
| ----- | -------- | ------------------ |
| name  | `string` | Name of the artist |

### setAlbum(name) ⇒ [`Spotify`](#Spotify)

Set the name of the album

**Kind**: global function\
**Returns**: [`Spotify`](#Spotify) - The current instance of Spotify\
**Throws**:

* `APIError` Album name expected but not received

| Param | Type     | Description       |
| ----- | -------- | ----------------- |
| name  | `string` | Name of the album |

### setStartTimestamp(time) ⇒ [`Spotify`](#Spotify)

Set start timestamp

**Kind**: global function\
**Returns**: [`Spotify`](#Spotify) - The current instance of Spotify\
**Throws**:

* `APIError` Timestamp expected but not received

| Param | Type               | Description |
| ----- | ------------------ | ----------- |
| time  | `Date` \| `number` | Timestamp   |

### setEndTimestamp(time) ⇒ [`Spotify`](#Spotify)

Set end timestamp

**Kind**: global function\
**Returns**: [`Spotify`](#Spotify) - The current instance of Spotify\
**Throws**:

* `APIError` Timestamp expected but not received

| Param | Type               | Description |
| ----- | ------------------ | ----------- |
| time  | `Date` \| `number` | Timestamp   |

### setBackground(type, data) ⇒ [`Spotify`](#Spotify)

Set background image/color of the card

**Kind**: global function\
**Returns**: [`Spotify`](#Spotify) - The current instance of Spotify\
**Throws**:

* `APIError` Missing background data

| Param | Type                                   | Description                  |
| ----- | -------------------------------------- | ---------------------------- |
| type  | `"COLOR"` \| `"IMAGE"`                 | Type of background           |
| data  | `string` \| `Buffer` \| `Canvas.Image` | Image URL or HTML color code |

### build(\[font]) ⇒ `Promise.<Buffer>`

Build the Spotify presence card

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Card image in buffer format\
**Throws**:

* `APIError` Missing of options

| Param   | Type     | Default               | Description             |
| ------- | -------- | --------------------- | ----------------------- |
| \[font] | `string` | `"&quot;Arial&quot;"` | Font to use in the card |


# Rank

### Classes

[Rank](#Rank)

### Functions

[setAvatar(avatarUrl, AvatarDecorationData, squareAvatar)](#setAvatar) ⇒ [`Rank`](#Rank)

Set the user avatar

[setBanner(bannerUrl, moreBackgroundBlur, disableBackgroundBlur, backgroundBrightness)](#setBanner) ⇒ [`Rank`](#Rank)

Set the user banner

[setBadges(flags, bot, frame, customBadges)](#setBadges) ⇒ [`Rank`](#Rank)

Set the user badges and frame

[setBorder(color, allign)](#setBorder) ⇒ [`Rank`](#Rank)

Set the border of the card

[setUsername(name, \[discriminator\], \[color\], \[customUsername\], \[customTag\])](#setUsername) ⇒ [`Rank`](#Rank)

Set the username of the user

[setCurrentXP(data, \[color\])](#setCurrentXP) ⇒ [`Rank`](#Rank)

Set the current experience

[setRequiredXP(data, \[color\])](#setRequiredXP) ⇒ [`Rank`](#Rank)

Set the required experience

[setRank(data, \[text\], \[display\])](#setRank) ⇒ [`Rank`](#Rank)

Set the user rank

[setLevel(data, \[text\])](#setLevel) ⇒ [`Rank`](#Rank)

Establece el nivel del usuario

[setProgressBar(color, \[fillType\], \[rounded\])](#setProgressBar) ⇒ [`Rank`](#Rank)

Set the progress bar

[setStatus(presenceStatus)](#setStatus) ⇒ [`Rank`](#Rank)

Set the user presence status

[setCreatedTimestamp(timestamp, customDate)](#setCreatedTimestamp) ⇒ [`Rank`](#Rank)

Set the user created timestamp

[build(\[font\])](#build) ⇒ `Promise.<Buffer>`

Build the rank card

### Rank

**Kind**: global class<br>

#### new Rank(userId)

Rank card creator

<details>

<summary>PREVIEW</summary>

\
![Rank Card Preview 1](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/rank_1.png) ![Rank Card Preview 2](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/rank_2.png) ![Rank Card Preview 3](https://raw.githubusercontent.com/SrGobi/canvacard/refs/heads/test/rank_3.png)

</details>

| Param  | Type     | Description |
| ------ | -------- | ----------- |
| userId | `string` | User ID     |

**Example**

```js
const rank = new canvacard.Rank(data.id)
  .setAvatar(data.avatarURL, data.avatar_decoration_data.asset)
  .setBanner(data.bannerURL, true)
  .setBadges(data.flags, data.bot, true)
  .setBorder(["#22274a", "#001eff"], "vertical")
  .setCurrentXP(userData.xp)
  .setRequiredXP(userData.requiredXP)
  .setRank(1, "RANK", true)
  .setLevel(20, "LEVEL", true)
  .setStatus("online")
  .setProgressBar(["#14C49E", "#FF0000"], "GRADIENT", true)
  .setUsername(data.global_name, data.discriminator)
  .setCreatedTimestamp(data.createdTimestamp);

const rankImage = await rank.build("Cascadia Code PL");
canvacard.write(rankImage, "./rank.png");
```

### setAvatar(avatarUrl, AvatarDecorationData, squareAvatar) ⇒ [`Rank`](#Rank)

Set the user avatar

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param                | Type      | Description             |
| -------------------- | --------- | ----------------------- |
| avatarUrl            | `string`  | Avatar URL              |
| AvatarDecorationData | `string`  | Avatar decoration asset |
| squareAvatar         | `boolean` | Square avatar           |

### setBanner(bannerUrl, moreBackgroundBlur, disableBackgroundBlur, backgroundBrightness) ⇒ [`Rank`](#Rank)

Set the user banner

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param                 | Type      | Description             |
| --------------------- | --------- | ----------------------- |
| bannerUrl             | `string`  | Banner URL              |
| moreBackgroundBlur    | `boolean` | More background blur    |
| disableBackgroundBlur | `boolean` | Disable background blur |
| backgroundBrightness  | `number`  | Background brightness   |

### setBadges(flags, bot, frame, customBadges) ⇒ [`Rank`](#Rank)

Set the user badges and frame

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param        | Type             | Description                      |
| ------------ | ---------------- | -------------------------------- |
| flags        | `number`         | User flags                       |
| bot          | `boolean`        | Whether the user is a bot or not |
| frame        | `boolean`        | Badge frame                      |
| customBadges | `Array.<string>` | Custom badges                    |

### setBorder(color, allign) ⇒ [`Rank`](#Rank)

Set the border of the card

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param  | Type                         | Description                                                   |
| ------ | ---------------------------- | ------------------------------------------------------------- |
| color  | `string` \| `Array.<string>` | HEX color of the border, can be gradient if 2 colors are used |
| allign | `string`                     | Gradient alignment if 2 colors are used                       |

### setUsername(name, \[discriminator], \[color], \[customUsername], \[customTag]) ⇒ [`Rank`](#Rank)

Set the username of the user

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param             | Type     | Default                 | Description               |
| ----------------- | -------- | ----------------------- | ------------------------- |
| name              | `string` |                         | Username of the user      |
| \[discriminator]  | `string` | `"&quot;0&quot;"`       | Discriminator of the user |
| \[color]          | `string` | `"&quot;#FFFFFF&quot;"` | Color of the username     |
| \[customUsername] | `string` | `null`                  | Custom username           |
| \[customTag]      | `string` | `null`                  | Custom tag                |

### setCurrentXP(data, \[color]) ⇒ [`Rank`](#Rank)

Set the current experience

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param    | Type     | Default                 | Description             |
| -------- | -------- | ----------------------- | ----------------------- |
| data     | `number` |                         | Current experience data |
| \[color] | `string` | `"&quot;#FFFFFF&quot;"` | Text color              |

### setRequiredXP(data, \[color]) ⇒ [`Rank`](#Rank)

Set the required experience

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param    | Type     | Default                 | Description              |
| -------- | -------- | ----------------------- | ------------------------ |
| data     | `number` |                         | Required experience data |
| \[color] | `string` | `"&quot;#FFFFFF&quot;"` | Text color               |

### setRank(data, \[text], \[display]) ⇒ [`Rank`](#Rank)

Set the user rank

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param      | Type      | Default              | Description                |
| ---------- | --------- | -------------------- | -------------------------- |
| data       | `number`  |                      | Rank data                  |
| \[text]    | `string`  | `"&quot;RANK&quot;"` | Display text               |
| \[display] | `boolean` | `false`              | Display system rank or not |

### setLevel(data, \[text]) ⇒ [`Rank`](#Rank)

Establece el nivel del usuario

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param   | Type     | Default               | Description  |
| ------- | -------- | --------------------- | ------------ |
| data    | `number` |                       | Level data   |
| \[text] | `string` | `"&quot;LEVEL&quot;"` | Display text |

### setProgressBar(color, \[fillType], \[rounded]) ⇒ [`Rank`](#Rank)

Set the progress bar

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param       | Type                         | Default               | Description                                                     |
| ----------- | ---------------------------- | --------------------- | --------------------------------------------------------------- |
| color       | `string` \| `Array.<string>` |                       | Color of the progress bar, can be gradient if 2 colors are used |
| \[fillType] | `string`                     | `"&quot;COLOR&quot;"` | Type of progress bar                                            |
| \[rounded]  | `boolean`                    | `true`                | Rounded corners of the progress bar                             |

### setStatus(presenceStatus) ⇒ [`Rank`](#Rank)

Set the user presence status

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param          | Type     | Description     |
| -------------- | -------- | --------------- |
| presenceStatus | `string` | Presence status |

### setCreatedTimestamp(timestamp, customDate) ⇒ [`Rank`](#Rank)

Set the user created timestamp

**Kind**: global function\
**Returns**: [`Rank`](#Rank) - The current instance of Rank\
**Throws**:

* `APIError` If the URL or asset is invalid

| Param      | Type               | Description                               |
| ---------- | ------------------ | ----------------------------------------- |
| timestamp  | `number`           | Timestamp of when the user joined Discord |
| customDate | `string` \| `Date` | Custom date format for the timestamp      |

### build(\[font]) ⇒ `Promise.<Buffer>`

Build the rank card

**Kind**: global function\
**Returns**: `Promise.<Buffer>` - Card image in buffer format\
**Throws**:

* `APIError` Missing field: data

| Param   | Type     | Default               | Description             |
| ------- | -------- | --------------------- | ----------------------- |
| \[font] | `string` | `"&quot;Arial&quot;"` | Font to use in the card |


# Plugins

### Plugins : `object`

**Kind**: global typedef\
**Properties**

| Name      | Type       | Description                 |
| --------- | ---------- | --------------------------- |
| circle    | `function` | Complement of circle        |
| convolute | `function` | Convolute complement        |
| abbrev    | `function` | Complement of abbreviations |


# Utils


# Abbreviate

### Members

[getFirstDigitsAsDecimal](#getFirstDigitsAsDecimal)

This method takes a large number like "9360" and converts it to a small decimal like "9.3". Used by `abbreviateNumber()` to form abbreviations such as "9.3K". For the moment, this method intentionally avoids rounding numbers for simplicity.

### Functions

[abbreviateNumber()](#abbreviateNumber)

The abbreviation follows the format seen in many games: K - thousands M - millions B - billons T - trillons

All numbers greater than billions follow the following format, using each letter of the alphabet paired with itself: AA BB ... ZZ

It supports all numbers up to almost a googol (100 zeros) and supports up to 92 zeros or 93 digits.

### getFirstDigitsAsDecimal

This method takes a large number like "9360" and converts it to a small decimal like "9.3". Used by `abbreviateNumber()` to form abbreviations such as "9.3K". For the moment, this method intentionally avoids rounding numbers for simplicity.

**Kind**: global variable<br>

### abbreviateNumber()

The abbreviation follows the format seen in many games: K - thousands M - millions B - billons T - trillons

All numbers greater than billions follow the following format, using each letter of the alphabet paired with itself: AA BB ... ZZ

It supports all numbers up to almost a googol (100 zeros) and supports up to 92 zeros or 93 digits.

**Kind**: global function


# Canvas

### Members

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

Generate the badge canvas

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

Generate the card background

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

Generate the card frame

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

Generate the edges of the card with a multi-color gradient

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

Generate the card text and avatar

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

This function generates the avatar frame

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

This function cuts the presence status on the card

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

Sets the presence status on the card

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

Generate the bot verification badge

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

Shadows for the canvas

### Functions

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

Generate the experience bar

### generateBadgesCanvas ⇒ `Promise.<Buffer>`

Generate the badge canvas

**Kind**: global variable\
**Returns**: `Promise.<Buffer>` - Canvas

| Param                   | Type             | Description          |
| ----------------------- | ---------------- | -------------------- |
| user                    | `Object`         | User object          |
| user.bot                | `string`         | If the user is a bot |
| user.id                 | `string`         | User ID              |
| user.flags              | `Object`         | User Badges          |
| user.discriminator      | `string`         | User Discriminator   |
| options                 | `Object`         | Object of options    |
| options.customBadges    | `Array.<string>` | Custom Badges        |
| options.overwriteBadges | `boolean`        | Overwrite the badges |

### genBase ⇒ `Promise.<Buffer>`

Generate the card background

**Kind**: global variable\
**Returns**: `Promise.<Buffer>` - Canvas

| Param      | Type     | Description       |
| ---------- | -------- | ----------------- |
| options    | `Object` | Object of options |
| avatarData | `string` | Avatar URL        |
| bannerData | `string` | Banner URL        |

### genFrame ⇒ `Promise.<Buffer>`

Generate the card frame

**Kind**: global variable\
**Returns**: `Promise.<Buffer>` - Canvas

| Param                   | Type           |
| ----------------------- | -------------- |
| badgesData              | `Object`       |
| badgesData.canvas       | `CanvasElemet` |
| badgesData.badgesLength | `string`       |
| options                 | `Object`       |
| options.badgesFrame     | `string`       |

### genBorder ⇒ `Promise.<Buffer>`

Generate the edges of the card with a multi-color gradient

**Kind**: global variable\
**Returns**: `Promise.<Buffer>` - Canvas

| Param                | Type                         | Description                                 |
| -------------------- | ---------------------------- | ------------------------------------------- |
| options              | `Object`                     | Options object                              |
| options.borderColor  | `string` \| `Array.<string>` | It can be a color or an array of colors     |
| options.borderAllign | `string`                     | Edge direction ('vertical' or 'horizontal') |

### genTextAndAvatar ⇒ `Promise.<Buffer>`

Generate the card text and avatar

**Kind**: global variable

| Param                  | Type               | Default               | Description                                  |
| ---------------------- | ------------------ | --------------------- | -------------------------------------------- |
| user                   | `Object`           |                       | User data                                    |
| user.username          | `string`           |                       | User name                                    |
| user.discriminator     | `string`           |                       | User discriminator                           |
| user.bot               | `boolean`          |                       | If the user is a bot                         |
| user.createdTimestamp  | `number`           |                       | User creation timestamp                      |
| user.id                | `string`           |                       | User ID                                      |
| options                | `Object`           |                       | Options object                               |
| options.customUsername | `string`           |                       | Custom username                              |
| options.usernameColor  | `string`           |                       | Username color                               |
| options.customSubtitle | `string`           |                       | Custom subtitle                              |
| options.subtitleColor  | `string`           |                       | Subtitle color                               |
| options.customDate     | `string` \| `Date` |                       | Custom date                                  |
| options.localDateType  | `string`           |                       | Local format for the date, for example, 'en' |
| options.customTag      | `string`           |                       | Custom tag                                   |
| options.tagColor       | `string`           |                       | HEX Color of the label                       |
| options.squareAvatar   | `boolean`          |                       | Change the shape of the avatar to a square   |
| options.presenceStatus | `boolean`          |                       | Show presence status                         |
| rankData               | `Object`           |                       | Range data                                   |
| avatarData             | `string`           |                       | Avatar URL                                   |
| \[font]                | `string`           | `"&quot;Arial&quot;"` | Typeface family                              |

### genAvatarFrame ⇒ `Promise.<Buffer>`

This function generates the avatar frame

**Kind**: global variable\
**Returns**: `Promise.<Buffer>` - Canvas

| Param                               | Type     | Description             |
| ----------------------------------- | -------- | ----------------------- |
| user                                | `Object` | User data               |
| user.avatar\_decoration\_data       | `Object` | Avatar decoration data  |
| user.avatar\_decoration\_data.asset | `string` | Avatar decoration asset |
| options                             | `Object` | Object of options       |
| options.presenceStatus              | `string` | User presence           |

### cutAvatarStatus ⇒ `Promise.<Buffer>`

This function cuts the presence status on the card

**Kind**: global variable\
**Returns**: `Promise.<Buffer>` - Canvas

| Param                  | Type                | Description             |
| ---------------------- | ------------------- | ----------------------- |
| canvasToEdit           | `Image` \| `Canvas` | Image or canvas to edit |
| options                | `Object`            | Object of options       |
| options.presenceStatus | `string`            | User presence           |

### genStatus ⇒ `Promise.<Buffer>`

Sets the presence status on the card

**Kind**: global variable\
**Returns**: `Promise.<Buffer>` - Canvas

| Param                  | Type                | Description             |
| ---------------------- | ------------------- | ----------------------- |
| canvasToEdit           | `Image` \| `Canvas` | Image or canvas to edit |
| options                | `Object`            | Object of options       |
| options.presenceStatus | `string`            | User presence           |

### genBotVerifBadge ⇒ `Promise.<Buffer>`

Generate the bot verification badge

**Kind**: global variable\
**Returns**: `Promise.<Buffer>` - Canvas

| Param         | Type     | Default               | Description                     |
| ------------- | -------- | --------------------- | ------------------------------- |
| user          | `Object` |                       | User object                     |
| user.username | `string` |                       | User name                       |
| user.flags    | `number` |                       | Numeric value of the user flags |
| \[font]       | `string` | `"&quot;Arial&quot;"` | Typeface family                 |

### addShadow ⇒ `Promise.<Buffer>`

Shadows for the canvas

**Kind**: global variable\
**Returns**: `Promise.<Buffer>` - Canvas

| Param        | Type                | Description             |
| ------------ | ------------------- | ----------------------- |
| canvasToEdit | `Image` \| `Canvas` | Image or canvas to edit |

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

Generate the experience bar

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

| Param                          | Type                         | Description                  |
| ------------------------------ | ---------------------------- | ---------------------------- |
| options                        | `Object`                     | Options object               |
| options.rankData               | `Object`                     | Rank data                    |
| options.rankData.currentXp     | `number`                     | User current XP              |
| options.rankData.requiredXp    | `number`                     | XP required to level up      |
| options.rankData.level         | `number`                     | User level                   |
| options.rankData.rank          | `number`                     | User rank                    |
| options.rankData.barColor      | `string` \| `Array.<string>` | Color of the XP bar          |
| options.rankData.levelColor    | `string`                     | Color of the level text      |
| options.rankData.autoColorRank | `boolean`                    | Automatically color the rank |


# Discord Time

### discordTime ⇒ `string`

Convert regular timestamp to Discord-like time.

**Kind**: global variable\
**Returns**: `string` - Discord-like time chain

| Param | Type               | Description          |
| ----- | ------------------ | -------------------- |
| time  | `Date` \| `number` | Timestamp to convert |


# Error

### APIError ⇐ `Error`

Error class for API errors

**Kind**: global class\
**Extends**: `Error`<br>

#### new APIError(message)

APIError class

**Returns**: [`APIError`](#APIError) - APIError object

| Param   | Type     | Description   |
| ------- | -------- | ------------- |
| message | `string` | Error message |


# Flags

### checkFlags ⇒ `Array.<string>`

Function to check flags and get the badges.

**Kind**: global variable\
**Returns**: `Array.<string>` - Badges array

| Param      | Type                 | Description   |
| ---------- | -------------------- | ------------- |
| flags      | `Object`             | Badges object |
| flagNumber | `BigInt` \| `string` | Badges number |


# Format and Validate Hex

### formatAndValidateHex ⇒ `string`

Formats and validates the hexadecimal code.

**Kind**: global variable\
**Returns**: `string` - Formatted and validated hexadecimal code

| Param | Type     | Description                                    |
| ----- | -------- | ---------------------------------------------- |
| hex   | `string` | Hexadecimal code for formatting and validation |
| alt   | `string` | Alternative color if code is invalid           |


# Format Time

### formatTime ⇒ `string`

Formats the timestamp into a date string.

**Returns**: `string` - Formatted date string

| Param | Type     | Description          |
| ----- | -------- | -------------------- |
| time  | `number` | Timestamp to convert |


# Format Variable

### formatVariable ⇒ `string`

Gets variables and types.

**Kind**: global variable\
**Returns**: `string` - The formatted variable

| Param    | Type     | Description            |
| -------- | -------- | ---------------------- |
| prefix   | `object` | The type of variable   |
| variable | `object` | The variable to change |


# Get Date or String

### getDateOrString ⇒ `string`

Gets a formatted date string or returns the input as is.

**Kind**: global variable\
**Returns**: `string` - The formatted date string or the original input.

| Param            | Type               | Default  | Description                                                           |
| ---------------- | ------------------ | -------- | --------------------------------------------------------------------- |
| dateInput        | `string` \| `Date` |          | The date to format. Can be a date string (ISO 8601) or a Date object. |
| createdTimestamp | `number`           |          | A fallback timestamp to use if dateInput is undefined or null.        |
| \[localDateType] | `string`           | `"'en'"` | The locale for the date format (default is English).                  |


# Icon

### getIconPath ⇒ `string`

Function to get the URL of a badge icon. If the icon is a relative path, it is transformed into an absolute URL pointing to the GitHub repository.

**Kind**: global variable\
**Returns**: `string` - Absolute URL of the icon.\
**Throws**:

* `APIError` If there is a problem building the icon URL.

| Param   | Type     | Description            |
| ------- | -------- | ---------------------- |
| iconUrl | `string` | Icon name or icon URL. |


# Is Number

### isNumber ⇒ `number`

Checks if the parameter is a number

**Kind**: global variable\
**Returns**: `number` - Parameter

| Param | Type     | Description        |
| ----- | -------- | ------------------ |
| param | `number` | Parameter to check |
| type  | `string` | Parameter type     |


# Is String

### isString ⇒ `string`

Checks if the parameter is a string

**Kind**: global variable\
**Returns**: `string` - Parameter

| Param | Type     | Description        |
| ----- | -------- | ------------------ |
| param | `string` | Parameter to check |
| type  | `string` | Parameter type     |


# Parse Image

### parseImg ⇒ `string`

Check if the custom badge is valid

**Kind**: global variable\
**Returns**: `string` - Image URL

| Param          | Type     | Description |
| -------------- | -------- | ----------- |
| imgStringImage | `string` | image URL   |


# Parse PNG

### parsePng ⇒ `string`

Check if the custom badge is valid

**Kind**: global variable\
**Returns**: `string` - Image URL

| Param     | Type     | Description |
| --------- | -------- | ----------- |
| imgString | `string` | Image URL   |


# Parse SVG

### Members

[parseSvg](#parseSvg) ⇒ `string`

Check if the custom badge is valid (SVG)

[validateImage](#validateImage) ⇒ `string`

Helper function to validate images

### parseSvg ⇒ `string`

Check if the custom badge is valid (SVG)

**Kind**: global variable\
**Returns**: `string` - Image URL

| Param     | Type     | Description |
| --------- | -------- | ----------- |
| imgString | `string` | Image URL   |

### validateImage ⇒ `string`

Helper function to validate images

**Kind**: global variable\
**Returns**: `string` - Image URL

| Param     | Type     | Description                       |
| --------- | -------- | --------------------------------- |
| imgString | `string` | Image URL                         |
| format    | `string` | Image format ('png', 'svg', etc.) |


# Shorten

### shorten ⇒ `string`

Shorten text to a specific length and add ellipses if necessary.

**Kind**: global variable\
**Returns**: `string` - Original or shortened text

| Param | Type     | Description                              |
| ----- | -------- | ---------------------------------------- |
| text  | `string` | Text to be shortened                     |
| len   | `number` | Maximum length of text before shortening |


# Truncate Text

### truncateText ⇒ `string`

Truncates text to a specified length and adds an ellipsis if necessary.

**Kind**: global variable\
**Returns**: `string` - The original or truncated text.

| Param      | Type      | Default | Description                                                                        |
| ---------- | --------- | ------- | ---------------------------------------------------------------------------------- |
| text       | `string`  |         | The text to be truncated.                                                          |
| \[limit]   | `number`  | `25`    | The maximum length of text before truncation (default is 25).                      |
| \[fromEnd] | `boolean` | `false` | If true, truncation will be performed from the end of the text (default is false). |


# Username

### parseUsername ⇒ `Object`

Function that parses the username to fit the canvas size.

**Kind**: global variable\
**Returns**: `Object` - { username: string, newSize: number, textLength: number }

| Param           | Type          | Default     | Description         |
| --------------- | ------------- | ----------- | ------------------- |
| username        | `string`      |             | User name           |
| ctx             | `Object`      |             | Canvas context      |
| ctx.fillStyle   | `string`      |             | Text color          |
| ctx.textAlign   | `string`      |             | Text alignment      |
| ctx.measureText | `TextMetrics` |             | Text size           |
| \[font]         | `string`      | `"'Arial'"` | Text source         |
| size            | `string`      |             | Text size           |
| maxLength       | `number`      |             | Maximum text length |


