text2matrix
v2.0.0
Published
Convert text strings into customizable pixel matrices with options for max height, letter spacing, and more. Ideal for LED displays and creative typographic applications.
Downloads
68
Maintainers
Readme
Text2Matrix
Introduction
Convert text strings into customizable pixel matrices with options for max height, letter spacing, and more. Ideal for LED displays and creative typographic applications.
Installation
npm install text2matrix
Usage
const { Font, Text } = require("text2matrix");
async function main() {
const text = "Hello World!";
const myFont = "myFont.ttf";
const font = await Font.fromPath(myFont);
const text = new Text(text, font, { fontSize: 16 });
text.draw(); // only node environment, creates a png file
const matrix = text.matrix; // returns a 2D array of grayscale values between 0 and 1
}