mirror of
				https://github.com/KevinMidboe/motdGO.git
				synced 2025-10-29 17:50:24 +00:00 
			
		
		
		
	update
This commit is contained in:
		
							
								
								
									
										51
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										51
									
								
								README.md
									
									
									
									
									
								
							| @@ -9,8 +9,53 @@ | |||||||
| A port of [figlet](http://www.figlet.org/) to golang.   | A port of [figlet](http://www.figlet.org/) to golang.   | ||||||
| Make it easier to use,add some new feature such as colorized outputs. | Make it easier to use,add some new feature such as colorized outputs. | ||||||
|  |  | ||||||
| ##Install |  | ||||||
|     go get -u github.com/getwe/figlet4go |  | ||||||
|  |  | ||||||
| ##Usage | ##Usage | ||||||
|  |  | ||||||
|  | ###Install | ||||||
|  |     go get -u github.com/getwe/figlet4go | ||||||
|  |  | ||||||
|  | ###Demo | ||||||
|  | ```go | ||||||
|  | package main | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	"github.com/fatih/color" | ||||||
|  | 	"github.com/getwe/figlet4go" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func main() { | ||||||
|  | 	str := "golang" | ||||||
|  | 	ascii := figlet4go.NewAsciiRender() | ||||||
|  | 	// most simple Usage | ||||||
|  | 	renderStr, _ := ascii.Render(str) | ||||||
|  | 	fmt.Println(renderStr) | ||||||
|  |  | ||||||
|  | 	// change the font color | ||||||
|  | 	options := figlet4go.NewRenderOptions() | ||||||
|  | 	options.FontColor = make([]color.Attribute, len(str)) | ||||||
|  | 	options.FontColor[0] = color.FgMagenta | ||||||
|  | 	options.FontColor[1] = color.FgYellow | ||||||
|  | 	options.FontColor[2] = color.FgBlue | ||||||
|  | 	options.FontColor[3] = color.FgCyan | ||||||
|  | 	options.FontColor[4] = color.FgRed | ||||||
|  | 	options.FontColor[5] = color.FgWhite | ||||||
|  | 	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) | ||||||
|  |  | ||||||
|  | } | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| package figlet | package figlet4go | ||||||
| 
 | 
 | ||||||
| // Build in source font | // Build in source font | ||||||
| func buildInFont() string { | func buildInFont() string { | ||||||
							
								
								
									
										40
									
								
								demo/demo.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								demo/demo.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | |||||||
|  | package main | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	"github.com/fatih/color" | ||||||
|  | 	"github.com/getwe/figlet4go" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func main() { | ||||||
|  | 	str := "golang" | ||||||
|  | 	ascii := figlet4go.NewAsciiRender() | ||||||
|  | 	// most simple Usage | ||||||
|  | 	renderStr, _ := ascii.Render(str) | ||||||
|  | 	fmt.Println(renderStr) | ||||||
|  |  | ||||||
|  | 	// change the font color | ||||||
|  | 	options := figlet4go.NewRenderOptions() | ||||||
|  | 	options.FontColor = make([]color.Attribute, len(str)) | ||||||
|  | 	options.FontColor[0] = color.FgMagenta | ||||||
|  | 	options.FontColor[1] = color.FgYellow | ||||||
|  | 	options.FontColor[2] = color.FgBlue | ||||||
|  | 	options.FontColor[3] = color.FgCyan | ||||||
|  | 	options.FontColor[4] = color.FgRed | ||||||
|  | 	options.FontColor[5] = color.FgWhite | ||||||
|  | 	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) | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| package figlet | package figlet4go | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"errors" | 	"errors" | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| package figlet | package figlet4go | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"errors" | 	"errors" | ||||||
							
								
								
									
										
											BIN
										
									
								
								screenshot/demo1.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								screenshot/demo1.jpg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 87 KiB | 
		Reference in New Issue
	
	Block a user