ascii-textify
is a TypeScript utility that creates an ASCII art representation of a text string, scaling it to fit specified dimensions. Each character in the text is replaced by a customizable symbol in the output.
To install the package, use pnpm
(or npm
):
pnpm add ascii-textify
# or
npm i ascii-textify
import { createAsciiArtString } from "ascii-textify";
const text = "PPROGER";
const options = {
width: 200,
height: 100,
symbol: "*",
};
const asciiArtString = createAsciiArtString(text, options);
console.log(asciiArtString);
import { generateAsciiImage } from "ascii-textify";
const text = "PPROGER";
const options = {
width: 800,
height: 400,
symbol: "*",
scaleFactor: 4
};
const asciiArtImage = generateAsciiImage(text, options);
console.log(asciiArtImage);
-
width
: The width of the canvas in pixels. -
height
: The height of the canvas in pixels. -
symbol
: (optional): The character used to create the ASCII art. Default is"*"
. -
existingCanvas
: (optional): An existingHTMLCanvasElement
instance. Useful for server-side usage withnode-canvas
or similar libraries. If not provided, a new canvas will be created in the browser usingdocument
.
-
scaleFactor
(optional): Scaling factor to increase or decrease the pixel density of the ASCII art. Default is1
. -
color
(optional): color is set as a string or hex
This project is licensed under the MIT License - see the LICENSE file for details.