figure

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 12 Imported by: 0

README ¶

ASCII Word Art for Go

Acknowledgements

This solution based on common-nighthawk/go-figure by Daniel Deutsch. Instead of forking, I decided to create a new repository since the last update was two years ago.

Changes that diverged from the original
  • Updated to the latest Go version.
  • Removed the features I wasn't using, such as the blink, dance, and scroll.
  • Addressed warnings (unused variables, etc., naming conventions, etc.) as reported by Goland.

Description

ASCII Word Art for Go prints beautiful ASCII art from text. It supports FIGlet files and most of its features. The original project by Daniel Deutsch package was inspired by the Ruby gem artii.

Installation

go get -u github.com/twistingmercury/go-figure

Basic Example

package main

import("github.com/twistingmercury/go-figure")

func main() {
  myFigure := figure.NewFigure("Hello World", "", true)
  myFigure.Print()
}
  _   _          _   _          __        __                 _       _ 
 | | | |   ___  | | | |   ___   \ \      / /   ___    _ __  | |   __| |
 | |_| |  / _ \ | | | |  / _ \   \ \ /\ / /   / _ \  | '__| | |  / _` |
 |  _  | |  __/ | | | | | (_) |   \ V  V /   | (_) | | |    | | | (_| |
 |_| |_|  \___| |_| |_|  \___/     \_/\_/     \___/  |_|    |_|  \__,_|

You can also make colorful figures:

package main

import (
	"github.com/twistingmercury/go-figure"
	"log"
)

var colors = []string{
  "red", "yellow", "green", "cyan", "blue", "purple", "white", "gray",
}

func main() {
  for _, color := range colors {
    myArt, _ := figure.NewColorFigure(phrase, "bulbhead", color, false)
    myArt.Print()
  }
}

color-font-example.png

🔗 Supported Fonts 🔗

Contributing

Because this project is small, we can dispense with formality. Submit a pull request, open an issue, request a change. All good!

Documentation ¶

Index ¶

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

func Asset ¶

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetInfo ¶

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func Write ¶

func Write(w io.Writer, fig Figure)

Write writes the Figure to the given io.Writer.

Types ¶

type Figure ¶

type Figure struct {
	// contains filtered or unexported fields
}

func NewColorFigure ¶

func NewColorFigure(phrase, fontName string, color string, strict bool) (fig Figure, err error)

NewColorFigure returns a new Figure with the given phrase, font, and color.

func NewFigure ¶

func NewFigure(phrase, fontName string, strict bool) Figure

NewFigure returns a new Figure with the given phrase and font.

func (*Figure) ColorString ¶

func (fig *Figure) ColorString() string

ColorString returns the Figure as a string with ANSI color codes.

func (*Figure) Print ¶

func (fig *Figure) Print()

Print prints the Figure to stdout.

func (*Figure) String ¶

func (fig *Figure) String() string

String returns the Figure as a string.

Directories ¶

Path Synopsis

Jump to

Keyboard shortcuts

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