A lightweight JavaScript library for generating bitmap-style ASCII art text. BitmapIt allows you to create customizable retro-style text displays with various styling options and character sets.
- Convert text to customizable bitmap patterns
- Multiple display characters (blocks, symbols, custom characters)
- Adjustable font dimensions and spacing
- Clean and simple API
- HTML output with custom colors
- Mobile-friendly and responsive
- Zero dependencies
npm install bitmapit
Or include directly in your HTML:
<script type="module">
import { BitmapFontGenerator } from './path/to/bitmapit/index.js';
</script>
import { BitmapFontGenerator, defaultFont } from 'bitmapit';
// Create generator
const generator = new BitmapFontGenerator();
// Define characters
Object.entries(defaultFont).forEach(([char, pattern]) => {
generator.defineCharacter(char, pattern);
});
// Generate text
const bitmap = generator.generateText('HELLO');
console.log(generator.toAscii(bitmap));
const generator = new BitmapFontGenerator({
width: 8, // Character width
height: 8, // Character height
spacing: 1 // Space between characters
});
const generator = new BitmapFontGenerator({
onChar: '█', // Character for filled pixels
offChar: ' ', // Character for empty pixels
color: '#ffffff', // Text color (HTML only)
backgroundColor: '#000000' // Background color (HTML only)
});
new BitmapFontGenerator(options)
Options:
width
(Number, default: 8): Width of each characterheight
(Number, default: 8): Height of each characterspacing
(Number, default: 1): Space between charactersonChar
(String, default: '█'): Character for filled pixelsoffChar
(String, default: ' '): Character for empty pixels
Define a new character pattern.
generator.defineCharacter('A', [
[0,1,1,1,0],
[1,0,0,0,1],
[1,1,1,1,1],
[1,0,0,0,1],
[1,0,0,0,1]
]);
Generate a bitmap pattern for the given text.
const bitmap = generator.generateText('HELLO');
Convert a bitmap to ASCII art.
const ascii = generator.toAscii(bitmap, {
on: '█',
off: ' '
});
Convert a bitmap to HTML with styling.
const html = generator.toHtml(bitmap, {
color: '#ff0000',
backgroundColor: '#000000',
on: '█',
off: ' '
});
Update the font dimensions.
generator.setDimensions(10, 10);
Set the spacing between characters.
generator.setSpacing(2);
- Chrome 61+
- Firefox 60+
- Safari 11+
- Edge 16+
Visit our demo page to try BitmapIt live and see various examples in action.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Created by Om Preetham
- Report issues on GitHub