> For the complete documentation index, see [llms.txt](https://canvacard.srgobi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://canvacard.srgobi.com/utils/canvas.utils.md).

# 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 |
