mirror of
https://github.com/KevinMidboe/motdGOi.git
synced 2025-12-29 21:31:04 +00:00
readme changes, other default font, go-bindata for default font, little commenting
This commit is contained in:
1
demo/colored.go
Normal file
1
demo/colored.go
Normal file
@@ -0,0 +1 @@
|
||||
package main
|
||||
22
demo/default.go
Normal file
22
demo/default.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// Print a simple string with the 'standard' figlet font
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/probandula/figlet4go"
|
||||
)
|
||||
|
||||
// String to be printed
|
||||
const str string = "Default"
|
||||
|
||||
func main() {
|
||||
// Create the renderer
|
||||
ascii := figlet4go.NewAsciiRender()
|
||||
|
||||
// Render the string
|
||||
renderStr, _ := ascii.Render(str)
|
||||
|
||||
// Print the string
|
||||
fmt.Print(renderStr)
|
||||
}
|
||||
49
demo/demo.go
49
demo/demo.go
@@ -1,49 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/fatih/color"
|
||||
"github.com/getwe/figlet4go"
|
||||
)
|
||||
|
||||
var flag_str = flag.String("str", "golang", "input string")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
str := *flag_str
|
||||
ascii := figlet4go.NewAsciiRender()
|
||||
// most simple Usage
|
||||
renderStr, _ := ascii.Render(str)
|
||||
fmt.Println(renderStr)
|
||||
|
||||
// change the font color
|
||||
colors := [...]color.Attribute{
|
||||
color.FgMagenta,
|
||||
color.FgYellow,
|
||||
color.FgBlue,
|
||||
color.FgCyan,
|
||||
color.FgRed,
|
||||
color.FgWhite,
|
||||
}
|
||||
options := figlet4go.NewRenderOptions()
|
||||
options.FontColor = make([]color.Attribute, len(str))
|
||||
for i := range options.FontColor {
|
||||
options.FontColor[i] = colors[i%len(colors)]
|
||||
}
|
||||
renderStr, _ = ascii.RenderOpts(str, options)
|
||||
fmt.Println(renderStr)
|
||||
|
||||
// change the font
|
||||
options.FontName = "larry3d"
|
||||
// except the default font,others need to be load from disk
|
||||
// here is the font :
|
||||
// ftp://ftp.figlet.org/pub/figlet/fonts/contributed.tar.gz
|
||||
// ftp://ftp.figlet.org/pub/figlet/fonts/international.tar.gz
|
||||
// download and extract to the disk,then specify the file path to load
|
||||
ascii.LoadFont("/usr/local/Cellar/figlet/2.2.5/share/figlet/fonts/")
|
||||
|
||||
renderStr, _ = ascii.RenderOpts(str, options)
|
||||
fmt.Println(renderStr)
|
||||
|
||||
}
|
||||
5
demo/otherfont.go
Normal file
5
demo/otherfont.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user