Top Related Projects
Drawing in terminal with unicode braille characters
Small C++ program to display images in a (modern) terminal using RGB ANSI codes and unicode block graphics characters
Rich is a Python library for rich text and beautiful formatting in the terminal.
:tea: All Gang of Four Design Patterns written in Unity C# with many examples. And some Game Programming Patterns written in Unity C#. | 各种设计模式的Unity3D C#版本实现
A high-level terminal interface library for node.js.
Quick Overview
Drawille is a Python library that allows you to create and manipulate text-based graphics using Unicode characters. It provides a simple and efficient way to generate and display ASCII-based drawings, charts, and visualizations in the terminal or other text-based environments.
Pros
- Cross-platform Compatibility: Drawille works on various operating systems, including Windows, macOS, and Linux, making it a versatile tool for developers and users.
- Lightweight and Efficient: The library is lightweight and efficient, with a small footprint and fast rendering capabilities, making it suitable for use in resource-constrained environments.
- Flexible API: Drawille offers a flexible API that allows users to easily create, manipulate, and display a wide range of text-based graphics.
- Integrates with Other Libraries: The library can be integrated with other Python libraries, such as Matplotlib, to create more complex visualizations and data representations.
Cons
- Limited to Text-based Environments: Drawille is primarily designed for text-based environments, such as the terminal, and may not be the best choice for creating high-resolution or graphical-intensive visualizations.
- Learning Curve: While the library is relatively easy to use, there may be a learning curve for users who are not familiar with text-based graphics or the Braille-based drawing technique used by Drawille.
- Lack of Advanced Features: Compared to more sophisticated visualization libraries, Drawille may lack some advanced features, such as support for interactive plots or complex color palettes.
- Potential Compatibility Issues: As a relatively niche library, Drawille may occasionally encounter compatibility issues with newer versions of Python or other dependencies.
Code Examples
Here are a few examples of how to use the Drawille library:
- Drawing a Simple Shape:
from drawille import Canvas, line
canvas = Canvas()
line(canvas, 5, 5, 20, 20)
print(canvas.frame())
This code creates a Canvas object, draws a line between the coordinates (5, 5) and (20, 20), and then prints the resulting frame.
- Generating a Sine Wave:
import math
from drawille import Canvas, line
canvas = Canvas()
for x in range(0, 80):
y = int(math.sin(x * 0.1) * 10) + 10
line(canvas, x, 0, x, y)
print(canvas.frame())
This code generates a sine wave by iterating over the x-axis, calculating the y-coordinate based on a sine function, and then drawing a line from the bottom of the canvas to the calculated y-coordinate.
- Integrating with Matplotlib:
import matplotlib.pyplot as plt
from drawille import Canvas, line
fig, ax = plt.subplots()
ax.plot([1, 2, 3, 4], [1, 4, 9, 16])
canvas = Canvas()
for x, y in zip(ax.get_xticks(), ax.get_yticks()):
line(canvas, x, y, x, y)
print(canvas.frame())
This example shows how to integrate Drawille with Matplotlib to create a text-based representation of a simple plot.
Getting Started
To get started with Drawille, you can install the library using pip:
pip install drawille
Once installed, you can import the necessary modules and start creating your text-based graphics. The following example demonstrates how to draw a simple shape:
from drawille import Canvas, line
canvas = Canvas()
line(canvas, 5, 5, 20, 20)
print(canvas.frame())
This code will output the following text-based representation of the drawn shape:
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Competitor Comparisons
Drawing in terminal with unicode braille characters
Pros of node-drawille
- Provides a Node.js implementation of the Drawille library, allowing for easy integration with Node.js projects.
- Supports a wider range of terminal emulators, including Windows PowerShell and Windows Command Prompt.
- Includes additional features like support for custom character sets and the ability to draw lines and shapes.
Cons of node-drawille
- May have a smaller user base and community compared to the original Drawille library.
- Potential for compatibility issues with certain Node.js versions or environments.
- May have a slightly higher learning curve for developers already familiar with the original Drawille library.
Code Comparison
asciimoo/drawille:
from drawille import Canvas, line
c = Canvas()
c.set(10, 10)
c.set(20, 20)
print(c.frame())
madbence/node-drawille:
const { Canvas, line } = require('node-drawille');
const c = new Canvas();
c.set(10, 10);
c.set(20, 20);
console.log(c.frame());
The code snippets demonstrate the similar usage of the Canvas
and line
functions in both the Python and Node.js implementations of the Drawille library.
Small C++ program to display images in a (modern) terminal using RGB ANSI codes and unicode block graphics characters
Pros of TerminalImageViewer
- Supports a wider range of image formats, including JPEG, PNG, and GIF, whereas Drawille is primarily focused on ASCII art.
- Provides a more user-friendly interface with keyboard controls for zooming, panning, and toggling between different display modes.
- Offers better performance and responsiveness when rendering images, especially larger ones.
Cons of TerminalImageViewer
- Requires additional dependencies, such as the Java Runtime Environment, which may not be available on all systems.
- The installation process may be more complex compared to Drawille, which is a single Python script.
- The project has a smaller community and fewer contributors compared to Drawille, which may result in slower development and fewer updates.
Code Comparison
Drawille (Python):
from drawille import Canvas, line
c = Canvas()
c.set(10, 10)
c.set(20, 20)
print(c.frame())
TerminalImageViewer (Java):
public static void main(String[] args) {
TerminalImageViewer viewer = new TerminalImageViewer();
viewer.showImage("path/to/image.jpg");
}
Rich is a Python library for rich text and beautiful formatting in the terminal.
Pros of Rich
- Rich provides a wide range of features for creating rich, formatted text in the terminal, including support for colors, styles, and emojis.
- The library has a large and active community, with extensive documentation and a wide range of examples.
- Rich integrates well with other popular Python libraries, such as Pandas and Matplotlib, making it a versatile tool for data visualization and reporting.
Cons of Rich
- Rich may have a larger memory footprint compared to Drawille, as it includes a more comprehensive set of features.
- The learning curve for Rich may be steeper than Drawille, as it has a more complex API and a wider range of functionality.
- Rich may not be as well-suited for creating simple, lightweight terminal-based applications as Drawille.
Code Comparison
Drawille:
from drawille import Canvas
c = Canvas()
c.set(10, 10)
print(c.frame())
Rich:
from rich.console import Console
from rich.text import Text
console = Console()
text = Text("Hello, World!", style="bold red")
console.print(text)
:tea: All Gang of Four Design Patterns written in Unity C# with many examples. And some Game Programming Patterns written in Unity C#. | 各 种设计模式的Unity3D C#版本实现
Pros of Unity-Design-Pattern
- Provides a comprehensive collection of design patterns implemented in Unity, covering a wide range of use cases.
- Includes detailed explanations and examples for each design pattern, making it easier for developers to understand and apply them.
- Offers a structured and organized approach to implementing design patterns in Unity projects.
Cons of Unity-Design-Pattern
- Primarily focused on Unity-specific design patterns, which may not be as applicable to non-Unity projects.
- The repository may not be as actively maintained as drawille, potentially leading to outdated information or lack of updates.
- The documentation, while detailed, may not be as concise or user-friendly as the drawille project.
Code Comparison
drawille
from drawille import Canvas
c = Canvas()
c.set(10, 10)
c.dump()
Unity-Design-Pattern
public class Singleton<T> where T : class, new()
{
private static T instance;
public static T Instance
{
get
{
if (instance == null)
{
instance = new T();
}
return instance;
}
}
}
The drawille project is a Python library for creating ASCII art using a terminal, while the Unity-Design-Pattern repository is a collection of design patterns implemented in C# for Unity projects. The code comparison shows the simplicity of the drawille library, where a single line of code can create a simple ASCII art canvas, compared to the more complex implementation of the Singleton design pattern in Unity-Design-Pattern.
A high-level terminal interface library for node.js.
Pros of Blessed
- Blessed provides a more comprehensive set of UI components and widgets, including text boxes, menus, and modal dialogs, making it easier to build complex terminal-based applications.
- Blessed has better support for handling user input and events, with built-in support for keyboard, mouse, and touch events.
- Blessed's rendering engine is more efficient and can handle larger and more complex terminal interfaces.
Cons of Blessed
- Blessed has a larger codebase and dependency tree, which can make it more difficult to set up and configure for smaller projects.
- Blessed's API can be more complex and less intuitive than Drawille, especially for simple terminal-based applications.
- Blessed may have a steeper learning curve for developers who are new to terminal-based UI development.
Code Comparison
Drawille:
from drawille import Canvas, line
c = Canvas()
c.set(10, 10)
c.set(20, 20)
print(c.frame())
Blessed:
const blessed = require('blessed');
const screen = blessed.screen();
const box = blessed.box({
top: 'center',
left: 'center',
width: '50%',
height: '50%',
content: 'Hello, world!',
border: {
type: 'line'
},
style: {
fg: 'white',
bg: 'magenta',
border: {
fg: '#f0f0f0'
}
}
});
screen.append(box);
screen.render();
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
DRAWILLE
Drawing in terminal with Unicode Braille characters
USAGE
from __future__ import print_function
from drawille import Canvas
from math import sin, radians
c = Canvas()
for x in range(0, 1800, 10):
c.set(x / 10, 10 + sin(radians(x)) * 10)
print(c.frame())
from drawille import Turtle
t = Turtle()
for _ in range(36):
t.right(10)
for _ in range(36):
t.right(10)
t.forward(8)
print(t.frame())
Installation
To install drawille, simply:
$ pip install drawille
or
$ easy_install drawille
Bugs
Bugs or suggestions? Visit the issue tracker.
Tested fonts
Font | Works |
---|---|
Terminus | Yes |
Fixed | Yes |
DejaVuSansMono | Yes |
Tested terminals
Terminal | Works |
---|---|
rxvt-unicode | Yes |
LICENSE
drawille is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
drawille is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with drawille. If not, see < http://www.gnu.org/licenses/ >.
(C) 2014- by Adam Tauber, <asciimoo@gmail.com>
Other implementations / similar projects
- https://github.com/null93/drawille (Java)
- https://github.com/madbence/node-drawille (nodejs)
- https://github.com/exrook/drawille-go (go)
- https://github.com/maerch/ruby-drawille (ruby)
- https://github.com/sunetos/TextPlots.jl (julia)
- https://github.com/mkremins/drawille-clj (clojure)
- https://github.com/mydzor/bash-drawille (bash)
- https://github.com/hoelzro/term-drawille (perl 5)
- https://github.com/whatthejeff/php-drawille (PHP)
- https://github.com/yamadapc/haskell-drawille (haskell)
- https://github.com/P1start/drawille-rs (rust)
- https://github.com/liam-middlebrook/drawille-sharp (C#)
- https://github.com/asciimoo/lua-drawille (Lua)
- https://github.com/l-a-i-n/drawille-plusplus (CPP)
- https://github.com/massn/elixir-drawille (elixir)
- https://github.com/sshbio/drawille (emacs lisp)
- https://gist.github.com/sshbio/### (awk, images only)
- https://github.com/Huulivoide/libdrawille (c)
- https://github.com/PMunch/drawille-nim (nim)
Further reading
Top Related Projects
Drawing in terminal with unicode braille characters
Small C++ program to display images in a (modern) terminal using RGB ANSI codes and unicode block graphics characters
Rich is a Python library for rich text and beautiful formatting in the terminal.
:tea: All Gang of Four Design Patterns written in Unity C# with many examples. And some Game Programming Patterns written in Unity C#. | 各种设计模式的Unity3D C#版本实现
A high-level terminal interface library for node.js.
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