Class: CardCreator

CardCreator(xivApiKeyopt)

new CardCreator(xivApiKeyopt)

Creates a new card creator.
Parameters:
Name Type Attributes Description
xivApiKey string <optional>
The API key for the XIV API to be used in all requests.
Source:

Members

canvasSize :CardCreator~CanvasDimensions

The canvas's dimensions.
Type:
Source:

Methods

(async) createCard(characterId, customImage, languageopt) → {Promise.<Buffer>}

Creates a character card for a character.
Parameters:
Name Type Attributes Default Description
characterId number | string The Lodestone ID of the character to generate a card for.
customImage string | Buffer | null | undefined Optional parameter providing a custom image to be drawn between the background of the character card and the black information boxes. The image should be the same resolution as the default image. The default image size can be retrieved with CardCreator#canvasSize. May be a URL, `data: `URI, a local file path, or a Buffer instance.
language string <optional>
en The language that the cards should be in use for the request
Source:
Returns:
A promise representating the construction of the card's image data.
Type
Promise.<Buffer>
Example
const fs = require('fs');

const card = new CardCreator();
const lodestoneId = '13821878';

await card.ensureInit();
const png = await card.createCard(lodestoneId);

fs.writeFile('./test.png', png, err => {
  if (err) console.error(err);
});

(async) ensureInit() → {Promise}

Ensures that the instance is ready to generate character cards. This function must be resolved before using character card generation methods.
Source:
Returns:
A promise representing the initialization state of this generator.
Type
Promise

Type Definitions

CanvasDimensions

Type:
  • Object
Properties:
Name Type Description
width number The width of the canvas.
height number The height of the canvas.
Source: