There are three ways to create a Figure. These are–
the method f'|## '\v/,
the method f'/## [, and
the method f'|## '\v/WithFont.
Each constructor takes the arguments: the text, font, and strict mode.
The “color” constructor takes a color as an additional arg.
The “with font” specifies the font differently.
The method signature are:
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1) requires only the name of the font, and uses the font file shipped
with this package stored in bindata.
If passed an empty string for the font name, a default is provided.
That is, these are both valid–
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont, on the other hand, accepts the font file directly.
This allows you to BYOF (bring your own font).
Provide the absolute path to the flf.
You can point to a file the comes with this project
or you can store the file anywhere you’d like and use that location.
Strict mode dictates how to handle characters outside of standard ASCII.
When set to true, a non-ASCII character (outside character codes 32-127)
will cause the program to panic.
When set to false, these characters are replaced with a question mark (‘?’).
Examples of each–
The most basic, and common, method is func Print.
A figure responds to Print(), and will write the output to the terminal.
There is no return value.
myFigure.Print()
But if you’re feeling adventurous,
explore the methods below.
Blink(duration, timeOn, timeOff int)
A figure responds to the func Blink, taking three arguments.
duration is the total time the banner will display, in milliseconds.
timeOn is the length of time the text will blink on (also in ms).
timeOff is the length of time the text will blink off (ms).
For an even blink, set timeOff to -1
(same as setting timeOff to the value of timeOn).
There is no return value.
myFigure.Blink(5000, 1000, 500)
myFigure.Blink(5000, 1000, -1)
Scroll(duration, stillness int, direction string)
A figure responds to the func Scroll, taking three arguments.
duration is the total time the banner will display, in milliseconds.
stillness is the length of time the text will not move (also in ms).
Therefore, the lower the stillness the faster the scroll speed.
direction can be either “right” or “left” (case insensitive).
The direction will be left if an invalid option (e.g. “foo”) is passed.
There is no return value.
myFigure.Scroll(5000, 200, "right")
myFigure.Scroll(5000, 100, "left")
Dance(duration, freeze int)
A figure responds to the func Dance, taking two arguments.
duration is the total time the banner will display, in milliseconds.
freeze is the length of time between dance moves (also in ms).
Therefore, the lower the freeze the faster the dancing.
There is no return value.
myFigure.Dance(5000, 800)
Methods: Writers
Write(w io.Writer, fig figure)
Unlike the above methods that operate on a figure value,
func Write is a function that takes two arguments.
w is a value that implements all the methods in the io.Writer interface.
fig is the figure that will be written.
figure.Write(w, myFigure)
This method would be useful, for example, to add a nifty banner to a web page–
func landingPage(w http.ResponseWriter, r *http.Request) {
figure.Write(w, myFigure)
}
Methods: Misc
Slicify() ([]string)
If you want to do something outside of the created methods,
you can grab the internal slice.
This gives you a good start to build anything
with the ASCII art, if manually.
A figure responds to the func Slicify,
and will return the slice of strings.
myFigure.Slicify()
returns
["FFFF BBBB ",
"F B B ",
"FFF ooo ooo BBBB aa rrr",
"F o o o o B B a a r ",
"F ooo ooo BBBB aaa r "]
More Examples
figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Go-Figure", "isometric1", true).Print()
figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("ABCDEFGHIJ", "eftichess", true).Print()
######### ######### ___ ######### #########
##[`'`']# [](https://travis-ci.com/common-nighthawk/go-figure)
# Go Figure
## Description
Go Figure prints beautiful ASCII art from text.
It supports [FIGlet](http://www.figlet.org/) files,
and most of its features.
This package was inspired by the Ruby gem [artii](https://github.com/miketierney/artii),
but built from scratch and with a different feature set.
## Installation
`g'/ ##'\v/`
## Basic Example
```go
package main
import("github.com/common-nighthawk/go-figure")
func main() {
myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Hello World", "", true)
myFigure.Print()
}
There are three ways to create a Figure. These are–
the method f'|## '\v/,
the method f'/## [, and
the method f'|## '\v/WithFont.
Each constructor takes the arguments: the text, font, and strict mode.
The “color” constructor takes a color as an additional arg.
The “with font” specifies the font differently.
The method signature are:
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1) requires only the name of the font, and uses the font file shipped
with this package stored in bindata.
If passed an empty string for the font name, a default is provided.
That is, these are both valid–
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont, on the other hand, accepts the font file directly.
This allows you to BYOF (bring your own font).
Provide the absolute path to the flf.
You can point to a file the comes with this project
or you can store the file anywhere you’d like and use that location.
Strict mode dictates how to handle characters outside of standard ASCII.
When set to true, a non-ASCII character (outside character codes 32-127)
will cause the program to panic.
When set to false, these characters are replaced with a question mark (‘?’).
Examples of each–
The most basic, and common, method is func Print.
A figure responds to Print(), and will write the output to the terminal.
There is no return value.
myFigure.Print()
But if you’re feeling adventurous,
explore the methods below.
Blink(duration, timeOn, timeOff int)
A figure responds to the func Blink, taking three arguments.
duration is the total time the banner will display, in milliseconds.
timeOn is the length of time the text will blink on (also in ms).
timeOff is the length of time the text will blink off (ms).
For an even blink, set timeOff to -1
(same as setting timeOff to the value of timeOn).
There is no return value.
myFigure.Blink(5000, 1000, 500)
myFigure.Blink(5000, 1000, -1)
Scroll(duration, stillness int, direction string)
A figure responds to the func Scroll, taking three arguments.
duration is the total time the banner will display, in milliseconds.
stillness is the length of time the text will not move (also in ms).
Therefore, the lower the stillness the faster the scroll speed.
direction can be either “right” or “left” (case insensitive).
The direction will be left if an invalid option (e.g. “foo”) is passed.
There is no return value.
myFigure.Scroll(5000, 200, "right")
myFigure.Scroll(5000, 100, "left")
Dance(duration, freeze int)
A figure responds to the func Dance, taking two arguments.
duration is the total time the banner will display, in milliseconds.
freeze is the length of time between dance moves (also in ms).
Therefore, the lower the freeze the faster the dancing.
There is no return value.
myFigure.Dance(5000, 800)
Methods: Writers
Write(w io.Writer, fig figure)
Unlike the above methods that operate on a figure value,
func Write is a function that takes two arguments.
w is a value that implements all the methods in the io.Writer interface.
fig is the figure that will be written.
figure.Write(w, myFigure)
This method would be useful, for example, to add a nifty banner to a web page–
func landingPage(w http.ResponseWriter, r *http.Request) {
figure.Write(w, myFigure)
}
Methods: Misc
Slicify() ([]string)
If you want to do something outside of the created methods,
you can grab the internal slice.
This gives you a good start to build anything
with the ASCII art, if manually.
A figure responds to the func Slicify,
and will return the slice of strings.
myFigure.Slicify()
returns
["FFFF BBBB ",
"F B B ",
"FFF ooo ooo BBBB aa rrr",
"F o o o o B B a a r ",
"F ooo ooo BBBB aaa r "]
More Examples
figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Go-Figure", "isometric1", true).Print()
There are three ways to create a Figure. These are–
the method f'|## '\v/,
the method f'/## [, and
the method f'|## '\v/WithFont.
Each constructor takes the arguments: the text, font, and strict mode.
The “color” constructor takes a color as an additional arg.
The “with font” specifies the font differently.
The method signature are:
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1) requires only the name of the font, and uses the font file shipped
with this package stored in bindata.
If passed an empty string for the font name, a default is provided.
That is, these are both valid–
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont, on the other hand, accepts the font file directly.
This allows you to BYOF (bring your own font).
Provide the absolute path to the flf.
You can point to a file the comes with this project
or you can store the file anywhere you’d like and use that location.
Strict mode dictates how to handle characters outside of standard ASCII.
When set to true, a non-ASCII character (outside character codes 32-127)
will cause the program to panic.
When set to false, these characters are replaced with a question mark (‘?’).
Examples of each–
The most basic, and common, method is func Print.
A figure responds to Print(), and will write the output to the terminal.
There is no return value.
myFigure.Print()
But if you’re feeling adventurous,
explore the methods below.
Blink(duration, timeOn, timeOff int)
A figure responds to the func Blink, taking three arguments.
duration is the total time the banner will display, in milliseconds.
timeOn is the length of time the text will blink on (also in ms).
timeOff is the length of time the text will blink off (ms).
For an even blink, set timeOff to -1
(same as setting timeOff to the value of timeOn).
There is no return value.
myFigure.Blink(5000, 1000, 500)
myFigure.Blink(5000, 1000, -1)
Scroll(duration, stillness int, direction string)
A figure responds to the func Scroll, taking three arguments.
duration is the total time the banner will display, in milliseconds.
stillness is the length of time the text will not move (also in ms).
Therefore, the lower the stillness the faster the scroll speed.
direction can be either “right” or “left” (case insensitive).
The direction will be left if an invalid option (e.g. “foo”) is passed.
There is no return value.
myFigure.Scroll(5000, 200, "right")
myFigure.Scroll(5000, 100, "left")
Dance(duration, freeze int)
A figure responds to the func Dance, taking two arguments.
duration is the total time the banner will display, in milliseconds.
freeze is the length of time between dance moves (also in ms).
Therefore, the lower the freeze the faster the dancing.
There is no return value.
myFigure.Dance(5000, 800)
Methods: Writers
Write(w io.Writer, fig figure)
Unlike the above methods that operate on a figure value,
func Write is a function that takes two arguments.
w is a value that implements all the methods in the io.Writer interface.
fig is the figure that will be written.
figure.Write(w, myFigure)
This method would be useful, for example, to add a nifty banner to a web page–
func landingPage(w http.ResponseWriter, r *http.Request) {
figure.Write(w, myFigure)
}
Methods: Misc
Slicify() ([]string)
If you want to do something outside of the created methods,
you can grab the internal slice.
This gives you a good start to build anything
with the ASCII art, if manually.
A figure responds to the func Slicify,
and will return the slice of strings.
myFigure.Slicify()
returns
["FFFF BBBB ",
"F B B ",
"FFF ooo ooo BBBB aa rrr",
"F o o o o B B a a r ",
"F ooo ooo BBBB aaa r "]
More Examples
figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Go-Figure", "isometric1", true).Print()
There are three ways to create a Figure. These are–
the method f'|## '\v/,
the method f'/## [, and
the method f'|## '\v/WithFont.
Each constructor takes the arguments: the text, font, and strict mode.
The “color” constructor takes a color as an additional arg.
The “with font” specifies the font differently.
The method signature are:
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1) requires only the name of the font, and uses the font file shipped
with this package stored in bindata.
If passed an empty string for the font name, a default is provided.
That is, these are both valid–
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont, on the other hand, accepts the font file directly.
This allows you to BYOF (bring your own font).
Provide the absolute path to the flf.
You can point to a file the comes with this project
or you can store the file anywhere you’d like and use that location.
Strict mode dictates how to handle characters outside of standard ASCII.
When set to true, a non-ASCII character (outside character codes 32-127)
will cause the program to panic.
When set to false, these characters are replaced with a question mark (‘?’).
Examples of each–
The most basic, and common, method is func Print.
A figure responds to Print(), and will write the output to the terminal.
There is no return value.
myFigure.Print()
But if you’re feeling adventurous,
explore the methods below.
Blink(duration, timeOn, timeOff int)
A figure responds to the func Blink, taking three arguments.
duration is the total time the banner will display, in milliseconds.
timeOn is the length of time the text will blink on (also in ms).
timeOff is the length of time the text will blink off (ms).
For an even blink, set timeOff to -1
(same as setting timeOff to the value of timeOn).
There is no return value.
myFigure.Blink(5000, 1000, 500)
myFigure.Blink(5000, 1000, -1)
Scroll(duration, stillness int, direction string)
A figure responds to the func Scroll, taking three arguments.
duration is the total time the banner will display, in milliseconds.
stillness is the length of time the text will not move (also in ms).
Therefore, the lower the stillness the faster the scroll speed.
direction can be either “right” or “left” (case insensitive).
The direction will be left if an invalid option (e.g. “foo”) is passed.
There is no return value.
myFigure.Scroll(5000, 200, "right")
myFigure.Scroll(5000, 100, "left")
Dance(duration, freeze int)
A figure responds to the func Dance, taking two arguments.
duration is the total time the banner will display, in milliseconds.
freeze is the length of time between dance moves (also in ms).
Therefore, the lower the freeze the faster the dancing.
There is no return value.
myFigure.Dance(5000, 800)
Methods: Writers
Write(w io.Writer, fig figure)
Unlike the above methods that operate on a figure value,
func Write is a function that takes two arguments.
w is a value that implements all the methods in the io.Writer interface.
fig is the figure that will be written.
figure.Write(w, myFigure)
This method would be useful, for example, to add a nifty banner to a web page–
func landingPage(w http.ResponseWriter, r *http.Request) {
figure.Write(w, myFigure)
}
Methods: Misc
Slicify() ([]string)
If you want to do something outside of the created methods,
you can grab the internal slice.
This gives you a good start to build anything
with the ASCII art, if manually.
A figure responds to the func Slicify,
and will return the slice of strings.
myFigure.Slicify()
returns
["FFFF BBBB ",
"F B B ",
"FFF ooo ooo BBBB aa rrr",
"F o o o o B B a a r ",
"F ooo ooo BBBB aaa r "]
More Examples
figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Go-Figure", "isometric1", true).Print()
Because this project is small, we can dispense with formality.
Submit a pull request, open an issue, request a change.
All good!
Wanna Say Thanks?
GitHub stars are helpful.
Most importantly, they help with discoverability.
Projects with more stars are displayed higher
in search results when people are looking for packages.
Also–they make contributors feel good :)
If you are feeling especially generous,
give a shout to @cmmn_nighthawk.
TODO
Add proper support for spaces
More animations
Implement graceful line-wrapping and smushing
Deep-copy font for Dance (current implementation is destructive)
Go Figure
Description
Go Figure prints beautiful ASCII art from text. It supports FIGlet files, and most of its features.
This package was inspired by the Ruby gem artii, but built from scratch and with a different feature set.
Installation
g'/ ##'\v/Basic Example
You can also make colorful figures:
Documentation
Create a Figure
There are three ways to create a Figure. These are– the method
f'|## '\v/, the methodf'/## [, and the methodf'|## '\v/WithFont.Each constructor takes the arguments: the text, font, and strict mode. The “color” constructor takes a color as an additional arg. The “with font” specifies the font differently. The method signature are:
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)requires only the name of the font, and uses the font file shipped with this package stored in bindata.If passed an empty string for the font name, a default is provided. That is, these are both valid–
myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo Bar", "", true)myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo Bar", "alphabet", true)Please note that font names are case sensitive.
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont, on the other hand, accepts the font file directly. This allows you to BYOF (bring your own font). Provide the absolute path to the flf. You can point to a file the comes with this project or you can store the file anywhere you’d like and use that location.The font files are available in the fonts folder and on figlet.org.
Here are two examples–
myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont("Foo Bar", "/home/ubuntu/go/src/github.com/common-nighthawk/go-figure/fonts/alphabet.flf", true)myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont("Foo Bar", "/home/lib/fonts/alaphabet.flf", true)You can also make colorful figures! The current supported colors are: blue, cyan, gray, green, purple, red, white, yellow.
An example–
`myFigure := figure.NewColorFigure(“Foo Bar”, “”, “green”, true)
Strict mode dictates how to handle characters outside of standard ASCII. When set to true, a non-ASCII character (outside character codes 32-127) will cause the program to panic. When set to false, these characters are replaced with a question mark (‘?’). Examples of each–
figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo 👍 Bar", "alphabet", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo 👍 Bar", "alphabet", false).Print()Methods: stdout
Print()
The most basic, and common, method is func Print. A figure responds to Print(), and will write the output to the terminal. There is no return value.
myFigure.Print()But if you’re feeling adventurous, explore the methods below.
Blink(duration, timeOn, timeOff int)
A figure responds to the func Blink, taking three arguments.
durationis the total time the banner will display, in milliseconds.timeOnis the length of time the text will blink on (also in ms).timeOffis the length of time the text will blink off (ms). For an even blink, settimeOffto -1 (same as settingtimeOffto the value oftimeOn). There is no return value.myFigure.Blink(5000, 1000, 500)myFigure.Blink(5000, 1000, -1)Scroll(duration, stillness int, direction string)
A figure responds to the func Scroll, taking three arguments.
durationis the total time the banner will display, in milliseconds.stillnessis the length of time the text will not move (also in ms). Therefore, the lower the stillness the faster the scroll speed.directioncan be either “right” or “left” (case insensitive). The direction will be left if an invalid option (e.g. “foo”) is passed. There is no return value.myFigure.Scroll(5000, 200, "right")myFigure.Scroll(5000, 100, "left")Dance(duration, freeze int)
A figure responds to the func Dance, taking two arguments.
durationis the total time the banner will display, in milliseconds.freezeis the length of time between dance moves (also in ms). Therefore, the lower the freeze the faster the dancing. There is no return value.myFigure.Dance(5000, 800)Methods: Writers
Write(w io.Writer, fig figure)
Unlike the above methods that operate on a figure value, func Write is a function that takes two arguments.
wis a value that implements all the methods in the io.Writer interface.figis the figure that will be written.figure.Write(w, myFigure)This method would be useful, for example, to add a nifty banner to a web page–
Methods: Misc
Slicify() ([]string)
If you want to do something outside of the created methods, you can grab the internal slice. This gives you a good start to build anything with the ASCII art, if manually.
A figure responds to the func Slicify, and will return the slice of strings.
myFigure.Slicify()returns
More Examples
figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Go-Figure", "isometric1", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo Bar Pop", "smkeyboard", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Keep Your Eyes On Me", "rectangles", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("ABCDEFGHIJ", "eftichess", true).Print()You can also make colorful figures:
Documentation
Create a Figure
There are three ways to create a Figure. These are– the method
f'|## '\v/, the methodf'/## [, and the methodf'|## '\v/WithFont.Each constructor takes the arguments: the text, font, and strict mode. The “color” constructor takes a color as an additional arg. The “with font” specifies the font differently. The method signature are:
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)requires only the name of the font, and uses the font file shipped with this package stored in bindata.If passed an empty string for the font name, a default is provided. That is, these are both valid–
myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo Bar", "", true)myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo Bar", "alphabet", true)Please note that font names are case sensitive.
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont, on the other hand, accepts the font file directly. This allows you to BYOF (bring your own font). Provide the absolute path to the flf. You can point to a file the comes with this project or you can store the file anywhere you’d like and use that location.The font files are available in the fonts folder and on figlet.org.
Here are two examples–
myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont("Foo Bar", "/home/ubuntu/go/src/github.com/common-nighthawk/go-figure/fonts/alphabet.flf", true)myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont("Foo Bar", "/home/lib/fonts/alaphabet.flf", true)You can also make colorful figures! The current supported colors are: blue, cyan, gray, green, purple, red, white, yellow.
An example–
`myFigure := figure.NewColorFigure(“Foo Bar”, “”, “green”, true)
Strict mode dictates how to handle characters outside of standard ASCII. When set to true, a non-ASCII character (outside character codes 32-127) will cause the program to panic. When set to false, these characters are replaced with a question mark (‘?’). Examples of each–
figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo 👍 Bar", "alphabet", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo 👍 Bar", "alphabet", false).Print()Methods: stdout
Print()
The most basic, and common, method is func Print. A figure responds to Print(), and will write the output to the terminal. There is no return value.
myFigure.Print()But if you’re feeling adventurous, explore the methods below.
Blink(duration, timeOn, timeOff int)
A figure responds to the func Blink, taking three arguments.
durationis the total time the banner will display, in milliseconds.timeOnis the length of time the text will blink on (also in ms).timeOffis the length of time the text will blink off (ms). For an even blink, settimeOffto -1 (same as settingtimeOffto the value oftimeOn). There is no return value.myFigure.Blink(5000, 1000, 500)myFigure.Blink(5000, 1000, -1)Scroll(duration, stillness int, direction string)
A figure responds to the func Scroll, taking three arguments.
durationis the total time the banner will display, in milliseconds.stillnessis the length of time the text will not move (also in ms). Therefore, the lower the stillness the faster the scroll speed.directioncan be either “right” or “left” (case insensitive). The direction will be left if an invalid option (e.g. “foo”) is passed. There is no return value.myFigure.Scroll(5000, 200, "right")myFigure.Scroll(5000, 100, "left")Dance(duration, freeze int)
A figure responds to the func Dance, taking two arguments.
durationis the total time the banner will display, in milliseconds.freezeis the length of time between dance moves (also in ms). Therefore, the lower the freeze the faster the dancing. There is no return value.myFigure.Dance(5000, 800)Methods: Writers
Write(w io.Writer, fig figure)
Unlike the above methods that operate on a figure value, func Write is a function that takes two arguments.
wis a value that implements all the methods in the io.Writer interface.figis the figure that will be written.figure.Write(w, myFigure)This method would be useful, for example, to add a nifty banner to a web page–
Methods: Misc
Slicify() ([]string)
If you want to do something outside of the created methods, you can grab the internal slice. This gives you a good start to build anything with the ASCII art, if manually.
A figure responds to the func Slicify, and will return the slice of strings.
myFigure.Slicify()returns
More Examples
figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Go-Figure", "isometric1", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo Bar Pop", "smkeyboard", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Keep Your Eyes On Me", "rectangles", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("ABCDEFGHIJ", "eftichess", true).Print()```~’/ ##’\v/
## /\*/\ ##|+’|## ‘\v/` ##Go Figure
Description
Go Figure prints beautiful ASCII art from text. It supports FIGlet files, and most of its features.
This package was inspired by the Ruby gem artii, but built from scratch and with a different feature set.
Installation
g'/ ##'\v/Basic Example
You can also make colorful figures:
Documentation
Create a Figure
There are three ways to create a Figure. These are– the method
f'|## '\v/, the methodf'/## [, and the methodf'|## '\v/WithFont.Each constructor takes the arguments: the text, font, and strict mode. The “color” constructor takes a color as an additional arg. The “with font” specifies the font differently. The method signature are:
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)requires only the name of the font, and uses the font file shipped with this package stored in bindata.If passed an empty string for the font name, a default is provided. That is, these are both valid–
myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo Bar", "", true)myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo Bar", "alphabet", true)Please note that font names are case sensitive.
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont, on the other hand, accepts the font file directly. This allows you to BYOF (bring your own font). Provide the absolute path to the flf. You can point to a file the comes with this project or you can store the file anywhere you’d like and use that location.The font files are available in the fonts folder and on figlet.org.
Here are two examples–
myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont("Foo Bar", "/home/ubuntu/go/src/github.com/common-nighthawk/go-figure/fonts/alphabet.flf", true)myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont("Foo Bar", "/home/lib/fonts/alaphabet.flf", true)You can also make colorful figures! The current supported colors are: blue, cyan, gray, green, purple, red, white, yellow.
An example–
`myFigure := figure.NewColorFigure(“Foo Bar”, “”, “green”, true)
Strict mode dictates how to handle characters outside of standard ASCII. When set to true, a non-ASCII character (outside character codes 32-127) will cause the program to panic. When set to false, these characters are replaced with a question mark (‘?’). Examples of each–
figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo 👍 Bar", "alphabet", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo 👍 Bar", "alphabet", false).Print()Methods: stdout
Print()
The most basic, and common, method is func Print. A figure responds to Print(), and will write the output to the terminal. There is no return value.
myFigure.Print()But if you’re feeling adventurous, explore the methods below.
Blink(duration, timeOn, timeOff int)
A figure responds to the func Blink, taking three arguments.
durationis the total time the banner will display, in milliseconds.timeOnis the length of time the text will blink on (also in ms).timeOffis the length of time the text will blink off (ms). For an even blink, settimeOffto -1 (same as settingtimeOffto the value oftimeOn). There is no return value.myFigure.Blink(5000, 1000, 500)myFigure.Blink(5000, 1000, -1)Scroll(duration, stillness int, direction string)
A figure responds to the func Scroll, taking three arguments.
durationis the total time the banner will display, in milliseconds.stillnessis the length of time the text will not move (also in ms). Therefore, the lower the stillness the faster the scroll speed.directioncan be either “right” or “left” (case insensitive). The direction will be left if an invalid option (e.g. “foo”) is passed. There is no return value.myFigure.Scroll(5000, 200, "right")myFigure.Scroll(5000, 100, "left")Dance(duration, freeze int)
A figure responds to the func Dance, taking two arguments.
durationis the total time the banner will display, in milliseconds.freezeis the length of time between dance moves (also in ms). Therefore, the lower the freeze the faster the dancing. There is no return value.myFigure.Dance(5000, 800)Methods: Writers
Write(w io.Writer, fig figure)
Unlike the above methods that operate on a figure value, func Write is a function that takes two arguments.
wis a value that implements all the methods in the io.Writer interface.figis the figure that will be written.figure.Write(w, myFigure)This method would be useful, for example, to add a nifty banner to a web page–
Methods: Misc
Slicify() ([]string)
If you want to do something outside of the created methods, you can grab the internal slice. This gives you a good start to build anything with the ASCII art, if manually.
A figure responds to the func Slicify, and will return the slice of strings.
myFigure.Slicify()returns
More Examples
figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Go-Figure", "isometric1", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo Bar Pop", "smkeyboard", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Keep Your Eyes On Me", "rectangles", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("ABCDEFGHIJ", "eftichess", true).Print()```~’/## [
'‘] ‘\v/`Go Figure
Description
Go Figure prints beautiful ASCII art from text. It supports FIGlet files, and most of its features.
This package was inspired by the Ruby gem artii, but built from scratch and with a different feature set.
Installation
g'/ ##'\v/Basic Example
You can also make colorful figures:
Documentation
Create a Figure
There are three ways to create a Figure. These are– the method
f'|## '\v/, the methodf'/## [, and the methodf'|## '\v/WithFont.Each constructor takes the arguments: the text, font, and strict mode. The “color” constructor takes a color as an additional arg. The “with font” specifies the font differently. The method signature are:
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)requires only the name of the font, and uses the font file shipped with this package stored in bindata.If passed an empty string for the font name, a default is provided. That is, these are both valid–
myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo Bar", "", true)myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo Bar", "alphabet", true)Please note that font names are case sensitive.
Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont, on the other hand, accepts the font file directly. This allows you to BYOF (bring your own font). Provide the absolute path to the flf. You can point to a file the comes with this project or you can store the file anywhere you’d like and use that location.The font files are available in the fonts folder and on figlet.org.
Here are two examples–
myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont("Foo Bar", "/home/ubuntu/go/src/github.com/common-nighthawk/go-figure/fonts/alphabet.flf", true)myFigure := figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)WithFont("Foo Bar", "/home/lib/fonts/alaphabet.flf", true)You can also make colorful figures! The current supported colors are: blue, cyan, gray, green, purple, red, white, yellow.
An example–
`myFigure := figure.NewColorFigure(“Foo Bar”, “”, “green”, true)
Strict mode dictates how to handle characters outside of standard ASCII. When set to true, a non-ASCII character (outside character codes 32-127) will cause the program to panic. When set to false, these characters are replaced with a question mark (‘?’). Examples of each–
figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo 👍 Bar", "alphabet", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo 👍 Bar", "alphabet", false).Print()Methods: stdout
Print()
The most basic, and common, method is func Print. A figure responds to Print(), and will write the output to the terminal. There is no return value.
myFigure.Print()But if you’re feeling adventurous, explore the methods below.
Blink(duration, timeOn, timeOff int)
A figure responds to the func Blink, taking three arguments.
durationis the total time the banner will display, in milliseconds.timeOnis the length of time the text will blink on (also in ms).timeOffis the length of time the text will blink off (ms). For an even blink, settimeOffto -1 (same as settingtimeOffto the value oftimeOn). There is no return value.myFigure.Blink(5000, 1000, 500)myFigure.Blink(5000, 1000, -1)Scroll(duration, stillness int, direction string)
A figure responds to the func Scroll, taking three arguments.
durationis the total time the banner will display, in milliseconds.stillnessis the length of time the text will not move (also in ms). Therefore, the lower the stillness the faster the scroll speed.directioncan be either “right” or “left” (case insensitive). The direction will be left if an invalid option (e.g. “foo”) is passed. There is no return value.myFigure.Scroll(5000, 200, "right")myFigure.Scroll(5000, 100, "left")Dance(duration, freeze int)
A figure responds to the func Dance, taking two arguments.
durationis the total time the banner will display, in milliseconds.freezeis the length of time between dance moves (also in ms). Therefore, the lower the freeze the faster the dancing. There is no return value.myFigure.Dance(5000, 800)Methods: Writers
Write(w io.Writer, fig figure)
Unlike the above methods that operate on a figure value, func Write is a function that takes two arguments.
wis a value that implements all the methods in the io.Writer interface.figis the figure that will be written.figure.Write(w, myFigure)This method would be useful, for example, to add a nifty banner to a web page–
Methods: Misc
Slicify() ([]string)
If you want to do something outside of the created methods, you can grab the internal slice. This gives you a good start to build anything with the ASCII art, if manually.
A figure responds to the func Slicify, and will return the slice of strings.
myFigure.Slicify()returns
More Examples
figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Go-Figure", "isometric1", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Foo Bar Pop", "smkeyboard", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Keep Your Eyes On Me", "rectangles", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("ABCDEFGHIJ", "eftichess", true).Print()figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Give your reasons", "doom", true).Blink(10000, 500, -1)figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("I mean, I could...", "basic", true).Scroll(10000, 200, "right")figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("But why would I want to?", "basic", true).Scroll(10000, 200, "left")figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("It's been waiting for you", "larry3d", true).Dance(10000, 500)figure.Write(w, figure.Nigure.NewFigure("Give your reasons", "doom", true).Blink(10000, 500, -1)("Hello, It's Me", "puffy", true))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!
Wanna Say Thanks?
GitHub stars are helpful. Most importantly, they help with discoverability. Projects with more stars are displayed higher in search results when people are looking for packages. Also–they make contributors feel good :)
If you are feeling especially generous, give a shout to @cmmn_nighthawk.
TODO