fancyhelloworld-demo
v1.0.0
Published
A fun JavaScript library that prints Hello World in ASCII art using 1s and 0s with customizable characters
Downloads
106
Maintainers
Readme
Fancy Hello World
This library was created for demo purposes for context7.
A fun JavaScript library that prints "Hello World" (or any custom text) in ASCII art using 1s and 0s, with customizable characters and styling options.
Installation
npm install fancyhelloworldOr if using locally:
npm installBasic Usage
const { fancyHelloWorld } = require("./index.js");
// Print "HELLO WORLD" in ASCII art with 1s and 0s
fancyHelloWorld();Output:
1 1 11111 1 1 111 1 1 111 1111 1 1111
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11111 1111 1 1 1 1 1 1 1 1 1111 1 1 1
1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 10 01 1 1 1 1 1 1 1
1 1 11111 11111 11111 111 1 1 111 1 1 11111 1111Configuration Options
The fancyHelloWorld() function accepts an options object with the following properties:
| Option | Type | Default | Description |
| --------------- | ------- | --------------- | ----------------------------------------------------------- |
| text | string | 'HELLO WORLD' | Custom text to display |
| caseSensitive | boolean | false | Whether to preserve case (converts to uppercase by default) |
| letterSpacing | number | 1 | Extra spaces between letters |
| fillChar | string | '1' | Character to use for filled pixels |
| emptyChar | string | '0' | Character to use for empty pixels |
Examples
Example 1: Custom Text (Case-Insensitive)
const { fancyHelloWorld } = require("./index.js");
// Works with lowercase, uppercase, or mixed case
fancyHelloWorld({ text: "hello world" });
fancyHelloWorld({ text: "HELLO" });
fancyHelloWorld({ text: "WoRLd" });All three will be converted to uppercase and displayed correctly.
Example 2: Custom Characters (Block Style)
const { fancyHelloWorld } = require("./index.js");
// Use block characters for a solid look
fancyHelloWorld({
text: "HELLO",
fillChar: "█",
emptyChar: "░",
});Output:
█ █ █████ █ █ ███
█ █ █ █ █ █ █
█████ ████ █ █ █ █
█ █ █ █ █ █ █
█ █ █ █ █ █ █
█ █ █ █ █ █ █
█ █ █████ █████ █████ ███Example 3: Asterisks and Dots
const { fancyHelloWorld } = require("./index.js");
// Use asterisks and dots for a classic look
fancyHelloWorld({
text: "WORLD",
fillChar: "*",
emptyChar: ".",
});Output:
* * .*** ***** * ****
* * * * * * * * *
* * * * * * * * *
* . * * * * * * * *
* . * * * * * * * *
** ** * * * * * * *
* * .*** ***** ***** ****Example 4: Increased Letter Spacing
const { fancyHelloWorld } = require("./index.js");
// Add more space between letters for better readability
fancyHelloWorld({
text: "HELLO",
letterSpacing: 3,
});This will add 3 spaces between each letter instead of the default 1.
Example 5: Emoji Style
const { fancyHelloWorld } = require("./index.js");
// Use emojis for a fun look
fancyHelloWorld({
text: "HELLO",
fillChar: "🔥",
emptyChar: "💧",
});Example 6: Hash and Dash Style
const { fancyHelloWorld } = require("./index.js");
// Programming/terminal style
fancyHelloWorld({
text: "HELLO",
fillChar: "#",
emptyChar: "-",
letterSpacing: 2,
});Example 7: X and O Pattern
const { fancyHelloWorld } = require("./index.js");
// Tic-tac-toe style
fancyHelloWorld({
text: "WORLD",
fillChar: "X",
emptyChar: "O",
});Supported Characters
Currently supported letters:
- Letters: H, E, L, O, W, R, D
- Special: Space
More letters can be added to the library by extending the letters object in the source code.
API Reference
fancyHelloWorld(options)
Prints text in ASCII art using 1s and 0s (or custom characters).
Parameters:
options(Object, optional): Configuration optionsoptions.text(string): The text to displayoptions.caseSensitive(boolean): Preserve original caseoptions.letterSpacing(number): Spaces between lettersoptions.fillChar(string): Character for filled pixelsoptions.emptyChar(string): Character for empty pixels
Returns: void (prints to console)
Example:
fancyHelloWorld({
text: "hello",
fillChar: "*",
emptyChar: ".",
letterSpacing: 2,
});License
MIT
Contributing
Feel free to submit issues and pull requests to add more letters or features!
