Top Related Projects
Pixel graphics in terminal with unicode braille characters
Terminal utilities for node.js
Create boxes in the terminal
🖍 Terminal string styling done right
Highly configurable logging utility
Quick Overview
Node-drawille is a lightweight Node.js library that allows you to draw ASCII art and simple graphics in the terminal using Braille characters. It provides a simple API for creating canvas objects and drawing basic shapes, enabling developers to create text-based visualizations and animations in the console.
Pros
- Easy to use API for drawing in the terminal
- Lightweight with no external dependencies
- Supports both Node.js and browser environments
- Allows for creative ASCII art and simple visualizations
Cons
- Limited to Braille characters, which may restrict complex designs
- Not suitable for high-resolution or detailed graphics
- May not display correctly on all terminal emulators
- Limited documentation and examples
Code Examples
Creating a simple canvas and drawing a line:
const Canvas = require('drawille');
const c = new Canvas();
c.line(0, 0, 10, 10);
console.log(c.frame());
Drawing a circle:
const Canvas = require('drawille');
const c = new Canvas();
c.circle(10, 10, 5);
console.log(c.frame());
Creating an animation:
const Canvas = require('drawille');
const c = new Canvas();
let i = 0;
setInterval(() => {
c.clear();
c.line(0, 0, i, 10);
console.log('\033[2J' + c.frame());
i = (i + 1) % 20;
}, 100);
Getting Started
To use node-drawille in your project, follow these steps:
-
Install the library using npm:
npm install drawille
-
Import the Canvas class in your JavaScript file:
const Canvas = require('drawille');
-
Create a new canvas and start drawing:
const c = new Canvas(); c.line(0, 0, 10, 10); console.log(c.frame());
That's it! You can now use the various drawing methods provided by the Canvas class to create your ASCII art and visualizations in the terminal.
Competitor Comparisons
Pixel graphics in terminal with unicode braille characters
Pros of drawille
- Written in Python, offering broader compatibility across platforms
- Includes additional drawing functions like ellipses and polygons
- Supports both Unicode and ASCII output modes
Cons of drawille
- Less actively maintained (last commit in 2019)
- Fewer stars and forks on GitHub, indicating potentially lower community adoption
- Limited to console/terminal output, lacking browser support
Code Comparison
drawille (Python):
from drawille import Canvas
c = Canvas()
c.set(0, 0)
c.set(1, 1)
c.set(2, 2)
print(c.frame())
node-drawille (JavaScript):
var Canvas = require('drawille');
var c = new Canvas();
c.set(0, 0);
c.set(1, 1);
c.set(2, 2);
console.log(c.frame());
Both libraries offer similar basic functionality for creating and manipulating canvas objects. The main difference lies in the language and ecosystem they operate in. node-drawille is tailored for Node.js applications, while drawille is more versatile for Python-based projects.
node-drawille benefits from JavaScript's widespread use in web development, potentially allowing for easier integration with web-based applications. It also has more recent updates and a larger community following.
Ultimately, the choice between these libraries depends on the specific project requirements, target platform, and developer preferences regarding programming language and ecosystem.
Terminal utilities for node.js
Pros of terminal-kit
- More comprehensive terminal manipulation capabilities, including input handling, color support, and advanced drawing functions
- Actively maintained with regular updates and a larger community
- Extensive documentation and examples for various use cases
Cons of terminal-kit
- Larger package size and potentially higher resource usage
- Steeper learning curve due to its extensive feature set
- May be overkill for simple terminal drawing tasks
Code comparison
terminal-kit:
const term = require('terminal-kit').terminal;
term.drawImage('path/to/image.png', {
shrink: { width: 80, height: 40 }
}).then(() => {
term.processExit(0);
});
node-drawille:
const Canvas = require('drawille');
const c = new Canvas(160, 160);
c.set(0, 0);
c.set(1, 1);
c.set(2, 2);
console.log(c.frame());
Summary
terminal-kit offers a more feature-rich and actively maintained solution for terminal manipulation, while node-drawille focuses specifically on simple ASCII drawing. terminal-kit is better suited for complex terminal applications, whereas node-drawille excels in lightweight, basic drawing tasks. The choice between the two depends on the project's requirements and complexity.
Create boxes in the terminal
Pros of boxen
- More actively maintained with recent updates
- Offers a wider range of customization options for creating boxes
- Has a larger community and more GitHub stars
Cons of boxen
- Focused solely on creating boxes, less versatile for other ASCII art
- Requires more setup and configuration for basic usage
- Larger package size due to additional features
Code Comparison
boxen:
import boxen from 'boxen';
console.log(boxen('Hello World', {padding: 1, borderColor: 'green'}));
node-drawille:
var Canvas = require('drawille');
var c = new Canvas(160, 160);
c.set(0, 0);
c.set(1, 1);
console.log(c.frame());
Key Differences
- boxen is specialized for creating text boxes with various styles and options
- node-drawille is more flexible, allowing for creation of various ASCII art and drawings
- boxen provides a higher-level API for quick box creation
- node-drawille offers lower-level control for pixel-by-pixel drawing
Use Cases
- Choose boxen for creating stylized text boxes in CLI applications
- Opt for node-drawille when needing to create custom ASCII art or drawings
Community and Support
- boxen has a larger user base and more frequent updates
- node-drawille has a smaller but dedicated community for ASCII art enthusiasts
🖍 Terminal string styling done right
Pros of chalk
- More actively maintained with frequent updates
- Broader functionality for terminal string styling
- Extensive documentation and examples
Cons of chalk
- Larger package size
- Focused solely on text styling, lacking drawing capabilities
Code comparison
chalk:
import chalk from 'chalk';
console.log(chalk.blue('Hello world!'));
console.log(chalk.blue.bgRed.bold('Hello world!'));
drawille:
var Canvas = require('drawille');
var c = new Canvas(160, 160);
c.set(0, 0);
c.set(1, 1);
c.frame();
Key differences
- Chalk is designed for text styling and coloring in the terminal
- drawille focuses on creating ASCII art and simple graphics using Braille characters
- Chalk has a larger community and more frequent updates
- drawille offers unique drawing capabilities not present in Chalk
Use cases
- Chalk: Ideal for enhancing CLI output with colors and styles
- drawille: Suitable for creating simple graphics or visualizations in terminal environments
Community and support
- Chalk has a larger user base and more active community support
- drawille has fewer contributors but offers a specialized functionality
Highly configurable logging utility
Pros of Signale
- More feature-rich logging capabilities with customizable loggers and themes
- Supports interactive logging with spinners and progress bars
- Actively maintained with recent updates and a larger community
Cons of Signale
- Larger package size and more dependencies
- Steeper learning curve due to more complex API
- May be overkill for simple logging needs
Code Comparison
Drawille:
var Canvas = require('drawille');
var c = new Canvas(160, 160);
c.set(0, 0);
c.set(1, 1);
console.log(c.frame());
Signale:
const { Signale } = require('signale');
const options = {
types: {
error: { badge: '!!', color: 'red' },
success: { badge: '✔', color: 'green' }
}
};
const signale = new Signale(options);
signale.success('Operation successful');
signale.error('Operation failed');
Summary
Signale is a more comprehensive logging solution with advanced features, while Drawille focuses on creating ASCII art and simple console graphics. Signale offers greater flexibility and customization for logging needs, but comes with a larger footprint and complexity. Drawille is simpler and more specialized for ASCII-based drawing tasks. Choose based on your specific requirements: Signale for rich logging capabilities, or Drawille for basic console graphics.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
node-drawille
drawing in terminal with unicode braille characters. The idea is based on drawille by @asciimoo.
install
install the package with npm
:
$ npm install --save drawille
usage
See examples.
this module provides a very basic API only, for fancy things, like drawing lines, use another module, like bresenham
.
drawille-canvas
provides HTML5 Canvas API for drawille.
api
Canvas(w, h)
Create a new canvas with the given dimensions.
w
must be multiple of 2, h
must be multiple of 4.
Uses columns
& rows
from process.stdout
as default values for w
and h
.
canvas.set(x, y)
Draw point on canvas
at the given position.
canvas.unset(x, y)
Delete point on canvas
at the given position.
canvas.toggle(x, y)
Toggle point on canvas
at the given position.
canvas.clear()
Clear the whole canvas (delete every point).
canvas.frame(delimiter)
return the current content of canvas
, as a delimiter
-delimited
string. delimiter
defaults to \n
.
it uses braille characters to represent points,
so every line has length of w/2
, and the string contains h/4
lines.
projects
vtop
uses it to draw CPU and memory usage charts in the terminaldatop
uses it to draw dat statisticsboscillate
uses it to drawbaudio
soundwaves in real-time
license
MIT
Top Related Projects
Pixel graphics in terminal with unicode braille characters
Terminal utilities for node.js
Create boxes in the terminal
🖍 Terminal string styling done right
Highly configurable logging utility
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot