Skip to content

jejebecarte/minecraft-text-canvas

Repository files navigation

Minecraft Text Canvas

A simple TypeScript application to generate images of Minecraft text using markup.

Installation

This package requires Node.js =>18.12.0.

Install via the package manager of your choice:

$ npm install minecraft-text-canvas
$ yarn add minecraft-text-canvas
$ pnpm add minecraft-text-canvas

Usage

The following example renders a sample input text with some basic markup:

import render, { CHAT_CODES } from 'minecraft-text-canvas';

const result = render(`${CHAT_CODES.RED.code}Example ${CHAT_CODES.AQUA.code}text`);

The result variable is of type TextCanvasResult, which allows the image to be retrieved as a PNG/JPEG Buffer or a PNG/JPEG Stream.

For usage examples pertaining to Streams, see the node-canvas documentation on creating PNG and JPEG streams.

Supported markup

Click to view
Name Code
Black &0
Dark Blue &1
Dark Green &2
Dark Aqua &3
Dark Red &4
Dark Purple &5
Gold &6
Gray &7
Dark Gray &8
Blue &9
Green &a
Aqua &b
Red &c
Light Purple &d
Yellow &e
White &f
Bold &l
Strikethrough &m
Underline &n
Italic &o
Reset &r
Newline \n

Acknowledgements

This repository was inspired by hypixel-fake-chat.

License

This is an open-source project under the MIT License.