mirror of
				https://github.com/KevinMidboe/motdGO.git
				synced 2025-10-29 17:50:24 +00:00 
			
		
		
		
	commenting
This commit is contained in:
		
							
								
								
									
										3
									
								
								char.go
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								char.go
									
									
									
									
									
								
							| @@ -6,6 +6,7 @@ import ( | |||||||
| 	"strings" | 	"strings" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | // Represents a single ascii character | ||||||
| type AsciiChar struct { | type AsciiChar struct { | ||||||
| 	// Slice with the lines of the Char | 	// Slice with the lines of the Char | ||||||
| 	Lines []string | 	Lines []string | ||||||
| @@ -13,6 +14,7 @@ type AsciiChar struct { | |||||||
| 	Color color.Attribute | 	Color color.Attribute | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Creates a new ascii character | ||||||
| func NewAsciiChar(font *font, char rune) (*AsciiChar, error) { | func NewAsciiChar(font *font, char rune) (*AsciiChar, error) { | ||||||
| 	// If not ascii, throw an error | 	// If not ascii, throw an error | ||||||
| 	if char < 0 || char > 127 { | 	if char < 0 || char > 127 { | ||||||
| @@ -24,6 +26,7 @@ func NewAsciiChar(font *font, char rune) (*AsciiChar, error) { | |||||||
|  |  | ||||||
| 	lines := make([]string, height) | 	lines := make([]string, height) | ||||||
|  |  | ||||||
|  | 	// Get the char lines of the char | ||||||
| 	for i := 0; i < height; i++ { | 	for i := 0; i < height; i++ { | ||||||
| 		row := font.fontSlice[beginRow+i] | 		row := font.fontSlice[beginRow+i] | ||||||
| 		row = strings.Replace(row, "@", "", -1) | 		row = strings.Replace(row, "@", "", -1) | ||||||
|   | |||||||
| @@ -97,7 +97,6 @@ func getColorSlice(colorStr string) []color.Attribute { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return colors | 	return colors | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| // Validate if all required options are given | // Validate if all required options are given | ||||||
|   | |||||||
| @@ -49,7 +49,7 @@ func (ar *AsciiRender) Render(str string) (string, error) { | |||||||
| // Can be called from the user (if options wished) or the above Render method | // Can be called from the user (if options wished) or the above Render method | ||||||
| // Contains the whole rendering logic | // Contains the whole rendering logic | ||||||
| func (ar *AsciiRender) RenderOpts(str string, opt *RenderOptions) (string, error) { | func (ar *AsciiRender) RenderOpts(str string, opt *RenderOptions) (string, error) { | ||||||
|  | 	// Should the text be colored | ||||||
| 	colored := len(opt.FontColor) > 0 | 	colored := len(opt.FontColor) > 0 | ||||||
|  |  | ||||||
| 	// Load the font | 	// Load the font | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user