minecraft-text-canvas
v1.2.1
Published
Generate images of Minecraft text using markup.
Downloads
15
Maintainers
Readme
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 Stream
s, see the node-canvas documentation on creating PNG and JPEG streams.
Supported markup
| 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.