dots

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2020 License: MIT Imports: 8 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(source image.Image, options ...Option) error

Write the image using Unicode braille characters.

Types

type Option

type Option func(*writeOpts) error

Option ...

func Invert

func Invert() Option

Invert the image. Braille will become the background, and empty space will be used as a drawing mechanism.

func Width

func Width(w int) Option

Width (in characters) for the length of each line of output.

func Writer

func Writer(w io.Writer) Option

Writer allows to override where the output is directed.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL