aboutsummaryrefslogtreecommitdiffstats
path: root/ascii.go
diff options
context:
space:
mode:
Diffstat (limited to 'ascii.go')
-rw-r--r--ascii.go43
1 files changed, 42 insertions, 1 deletions
diff --git a/ascii.go b/ascii.go
index 844ec94..da4a3b3 100644
--- a/ascii.go
+++ b/ascii.go
@@ -2,6 +2,7 @@ package main
import (
"io/ioutil"
+ "strings"
"github.com/inconshreveable/log15"
"github.com/kardianos/osext"
@@ -12,6 +13,28 @@ type ASCIICharacterMap map[rune]string
var chars ASCIICharacterMap
+// ASCIIRuneArray returns an 'ascii-art' representation of the given rune array
+func ASCIIRuneArray(characters []rune) string {
+ // var asciiString string
+
+ var stringArray [][]string
+
+ for _, aRune := range characters {
+ stringArray = append(stringArray, strings.Split(ASCIICharacter(aRune), "\n"))
+ // asciiString += ASCIICharacter(aRune)
+ }
+
+ var asciiString string
+ for i := 0; i < len(stringArray[0]); i++ {
+ for j := range stringArray {
+ asciiString += stringArray[j][i]
+ }
+ asciiString += "\n"
+ }
+
+ return asciiString
+}
+
// ASCIICharacter returns an 'ascii-art' representation of the given rune
func ASCIICharacter(character rune) string {
if asciiChar, ok := chars[character]; ok {
@@ -40,7 +63,25 @@ func init() {
func loadCharMap(charmap string) ASCIICharacterMap {
newCharMap := make(map[rune]string)
- newCharMap['r'] = "R"
+ chars := strings.Split(charmap, "===")
+
+ for i, char := range chars {
+ params := strings.Split(char, "---")
+ if len(params) != 2 {
+ if params[0] == "" || params[0] == "\n" {
+ log15.Info("Parsed charmap", "runes", i)
+ break
+ } else {
+ log15.Error("syntax error in charmap", "index", i)
+ return newCharMap
+ }
+ }
+ forRunes := []rune(string(params[0][:]))
+
+ for _, aRune := range forRunes {
+ newCharMap[aRune] = params[1]
+ }
+ }
return newCharMap
}