Skip to content

Latest commit

 

History

History
80 lines (68 loc) · 6.16 KB

README.md

File metadata and controls

80 lines (68 loc) · 6.16 KB

dots

Golang package that converts images to be represented with braille unicode characters.

This style works best with line art images, since unlike other ascii art styles, braille doesn't support any kind of shading or gradient. A braille dot is either there to represent a pixel, or it isn't.

Color support may be added in the future.

Example

package main

import (
	"image"
	"log"
	"os"

	"github.com/glibsm/dots"
)

func main() {
	bytes, err := os.Open("~/foo/bar")
	if err != nil {
		log.Fatal(err)
	}
	img, _, err := image.Decode(bytes)
	if err != nil {
		log.Fatal(err)
	}

	if err := dots.Write(img, dots.Width(100)); err != nil {
		log.Fatal(err)
	}
}

Executable

This repo also contains a lightweight executable which makes use of the library for your CLI needs.

❯ go get -u github.com/glibsm/dots/cmd/dots
❯ dots -s ./examples/wizard.jpg -w 60
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣤⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣾⡿⠛⠛⠛⠿⣿⣷⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣤⣄⠠⣿⣦⣤⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⠏⠀⠀⠀⠀⠀⠀⢻⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣿⣷⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⠏⠀⠀⠀⢀⣶⡶⠀⠈⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣶⣦⡀⢸⣿⡿⣿⣿⣿⣿⡆⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⡟⠀⠀⠀⠀⢸⣿⣿⣆⠀⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣼⣿⡇⢹⣿⡇⣿⣿⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡇⠀⠀⠀⠀⠘⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⡿⠁⢸⣿⡇⢹⣿⡄⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣸⣿⡇⠀⠀⠀⠀⠀⢻⣿⣶⣉⣉⣥⣤⣤⣄⣀⡀⠀⠀⠀⠀⠀⢹⣿⠋⠉⠁⠀⠻⠟⠀⢸⣿⡇⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣾⣿⢹⣿⡇⠀⠀⠀⠀⠀⠀⠀⠻⠿⠟⠛⠛⠛⢛⣻⣿⣷⣶⠆⠀⣠⣿⡿⣀⣤⣤⣤⣤⣤⣀⠈⣿⣿⡄⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢿⣿⣿⣶⣶⣶⣿⠿⠛⠁⠈⠻⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣴⣾⣿⠿⠛⠋⠁⠀⣾⣿⣿⣿⠿⠟⠋⠉⠛⠛⢿⣷⡄⢻⣿⡀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠿⣿⣯⣍⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣤⣶⣿⣿⠿⠛⠋⠁⠀⠀⠀⠀⠀⢸⣿⣿⣿⣇⠀⠀⠀⠀⠀⠀⢸⣿⡇⢸⣿⡇⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠻⠿⢿⣿⣷⣶⣶⣶⣾⣿⡿⢿⡟⠛⢋⣵⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣻⣿⣿⣯⠀⠀⣀⠀⠀⣠⣾⡿⠀⣼⣿⠃⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⣾⣿⠿⢿⣿⣿⣿⠿⠿⣿⣿⠟⠁⠀⡀⠀⠀⠀⠀⢀⣠⣴⣾⡿⢟⣿⣿⣦⣴⣦⣤⣾⣿⣿⣡⣼⣿⠏⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣻⣿⡄⠀⠙⠃⠀⠀⠀⠉⠁⠀⣠⣿⣿⣶⣄⣤⣾⣿⠟⣫⣵⣾⣿⠟⠻⠿⡿⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⢠⣾⣿⣿⠿⣿⣦⡀⠀⢠⣤⠀⢀⣤⣾⣿⢟⣭⣿⣿⠟⣫⣴⣿⡿⠛⠉⠀⠀⠀⠀⠀⠉⠛⠿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⠟⠑⠀⠀⠉⠻⢿⣿⣾⣿⣿⠿⠟⢫⣴⣿⣿⣯⣴⣾⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⡿⢟⣿⣿⠟⢻⣿⡸⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⡿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⡅⢀⣸⣿⣇⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠇⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿⣿⠟⣿⣿⣵⣶⣿⠟⢻⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡄⢀⣀⣀⡀⢀⣤⣾⣿⣿⣿⡿⠋⠁⠀⣿⡟⠛⠉⠀⠀⣾⣿⣿⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⡿⠿⢿⣿⣿⣿⣿⡿⠟⠁⠀⠀⠀⠀⢿⣿⣦⣄⣤⣼⣿⣿⣿⡃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣾⣿⡟⠀⠀⣨⣿⣿⠟⠋⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠛⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣏⣀⢶⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣼⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠐⠿⠿⠋⠉⠙⢿⣿⣿⠿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⢿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣠⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⢿⣷⣦⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⡿⣿⣿⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠻⠿⢿⣷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢿⣿⡀⠙⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣴⣶⣿⣿⣷⣦⣀⣀⣀⣀⣠⣾⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣾⡿⠛⠁⠀⠀⠈⢻⣿⡿⠿⠿⠿⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⢿⣷⣤⡀⠀⠀⠀⠀⠀⠀⣀⣠⣴⣶⣿⠿⠿⣿⣿⣶⣤⣤⣴⣶⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠻⠿⣿⣷⣶⣶⣾⣿⠿⠟⠋⠁⠀⠀⠀⠀⠈⠉⠋⠉⠉⠉⠀⠀⠀

Image courtesy of https://opengameart.org/users/gfx0