A powerful React library for creating ASCII art animations and interactive ASCII-based applications. Built with TypeScript and modern React practices. This is a React port of play.core by Andreas Gysin.
- 🎨 High-performance ASCII rendering with both text and canvas-based renderers
- 📐 Precise character metrics calculation for perfect ASCII art alignment
- 🎥 Built-in animation support with FPS monitoring
- 🖼️ Image processing and conversion to ASCII art
- 🎮 Interactive cursor and input handling
- 🎯 Vector operations (2D and 3D)
- 🎨 Color support for terminal and canvas rendering
- 📦 Modular architecture with separate modules for different functionalities
npm install react-ascii-play
# or
yarn add react-ascii-play
# or
pnpm add react-ascii-playimport { AsciiRendererSettings, ReactAsciiPlay } from 'react-ascii-play';
function MyAsciiApp() {
const program = {
// Your ASCII art program logic here
pre: (context, cursor, buffer, userData) => {
// Pre logic
},
main: (context, cursor, buffer, userData) => {
// Main logic
},
post: (context, cursor, buffer, userData) => {
// Post logic
},
pointerMove: (context, cursor, buffer, userData, eventData) => {
// Pointer move logic
},
pointerDown: (context, cursor, buffer, userData, eventData) => {
// Pointer down logic
},
pointerUp: (context, cursor, buffer, userData, eventData) => {
// Pointer up logic
},
keyDown: (context, cursor, buffer, userData, eventData) => {
// Key down logic
},
};
const settings: AsciiRendererSettings = {
width: 80,
height: 24,
renderer: 'text', // or 'canvas'
fps: 60
};
return (
<ReactAsciiPlay
program={program}
settings={settings}
/>
);
}The main component for rendering ASCII art.
interface ReactAsciiPlayProps {
program: AsciiRendererProgram;
settings: AsciiRendererSettings;
className?: string;
loop?: (callback: AnimationCallback) => void;
}The library exports several modules for different functionalities:
buffer: Buffer manipulation utilitiescamera: Camera and viewport managementcanvas: Canvas rendering utilitiescolor: Color manipulation and conversiondrawInfo: Drawing information utilitiesexportframe: Frame export functionalityfiledownload: File download utilitiesimage: Image processing and conversionload: Asset loading utilitiesnum: Numerical utilitiessort: Sorting utilitiesvec2: 2D vector operationsvec3: 3D vector operationssdf: Signed Distance Field utilities
Check out the examples directory for more detailed usage examples.
Contributions are welcome! Please feel free to submit a Pull Request.
Apache License 2.0 © @ignmandagaran
This project is a port of play.core which is also licensed under Apache License 2.0.