aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--ascii.go43
-rw-r--r--charmap.txt525
-rw-r--r--main.go12
4 files changed, 422 insertions, 160 deletions
diff --git a/.gitignore b/.gitignore
index 40b9d60..f1c9251 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-asciigen
+asciiartfont
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
}
diff --git a/charmap.txt b/charmap.txt
index 9dc5184..c43058b 100644
--- a/charmap.txt
+++ b/charmap.txt
@@ -1,259 +1,486 @@
-
-
-
- █████╗
+Aa
+---
+ █████╗
██╔══██╗
███████║
██╔══██║
██║ ██║
╚═╝ ╚═╝
-
-
-
-
-██████╗
+===
+Bb
+---
+██████╗
██╔══██╗
██████╔╝
██╔══██╗
██████╔╝
-╚═════╝
-
-
-
-
+╚═════╝
+===
+Cc
+---
██████╗
██╔════╝
-██║
-██║
+██║
+██║
╚██████╗
╚═════╝
-
-
-
-
-██████╗
+===
+Dd
+---
+██████╗
██╔══██╗
██║ ██║
██║ ██║
██████╔╝
-╚═════╝
-
-
-
-
+╚═════╝
+===
+Ee
+---
███████╗
██╔════╝
-█████╗
-██╔══╝
+█████╗
+██╔══╝
███████╗
╚══════╝
-
-
-
-
+===
+Ff
+---
███████╗
██╔════╝
-█████╗
-██╔══╝
-██║
-╚═╝
-
-
-
-
- ██████╗
-██╔════╝
+█████╗
+██╔══╝
+██║
+╚═╝
+===
+Gg
+---
+ ██████╗
+██╔════╝
██║ ███╗
██║ ██║
╚██████╔╝
- ╚═════╝
-
-
-
-
+ ╚═════╝
+===
+Hh
+---
██╗ ██╗
██║ ██║
███████║
██╔══██║
██║ ██║
╚═╝ ╚═╝
-
-
-
-
+===
+Ii
+---
██╗
██║
██║
██║
██║
╚═╝
-
-
-
-
+===
+Jj
+---
██╗
██║
██║
██ ██║
╚█████╔╝
- ╚════╝
-
-
-
-
+ ╚════╝
+===
+Kk
+---
██╗ ██╗
██║ ██╔╝
-█████╔╝
-██╔═██╗
+█████╔╝
+██╔═██╗
██║ ██╗
╚═╝ ╚═╝
-
-
-
-
-██╗
-██║
-██║
-██║
+===
+Ll
+---
+██╗
+██║
+██║
+██║
███████╗
╚══════╝
-
-
-
-
+===
+Mm
+---
███╗ ███╗
████╗ ████║
██╔████╔██║
██║╚██╔╝██║
██║ ╚═╝ ██║
╚═╝ ╚═╝
-
-
-
-
+===
+Nn
+---
███╗ ██╗
████╗ ██║
██╔██╗ ██║
██║╚██╗██║
██║ ╚████║
╚═╝ ╚═══╝
-
-
-
-
- ██████╗
+===
+Oo
+---
+ ██████╗
██╔═══██╗
██║ ██║
██║ ██║
╚██████╔╝
- ╚═════╝
-
-
-
-
-██████╗
+ ╚═════╝
+===
+Pp
+---
+██████╗
██╔══██╗
██████╔╝
-██╔═══╝
-██║
-╚═╝
-
-
-
-
- ██████╗
+██╔═══╝
+██║
+╚═╝
+===
+Qq
+---
+ ██████╗
██╔═══██╗
██║ ██║
██║▄▄ ██║
╚██████╔╝
- ╚══▀▀═╝
-
-
-
-
-██████╗
+ ╚══▀▀═╝
+===
+Rr
+---
+██████╗
██╔══██╗
██████╔╝
██╔══██╗
██║ ██║
╚═╝ ╚═╝
-
-
-
-
+===
+Ss
+---
███████╗
██╔════╝
███████╗
╚════██║
███████║
╚══════╝
-
-
-
-
+===
+Tt
+---
████████╗
╚══██╔══╝
- ██║
- ██║
- ██║
- ╚═╝
-
-
-
-
+ ██║
+ ██║
+ ██║
+ ╚═╝
+===
+Uu
+---
██╗ ██╗
██║ ██║
██║ ██║
██║ ██║
╚██████╔╝
- ╚═════╝
-
-
-
-
+ ╚═════╝
+===
+Vv
+---
██╗ ██╗
██║ ██║
██║ ██║
╚██╗ ██╔╝
- ╚████╔╝
- ╚═══╝
-
-
-
-
+ ╚████╔╝
+ ╚═══╝
+===
+Ww
+---
██╗ ██╗
██║ ██║
██║ █╗ ██║
██║███╗██║
╚███╔███╔╝
- ╚══╝╚══╝
-
-
-
-
+ ╚══╝╚══╝
+===
+Xx
+---
██╗ ██╗
╚██╗██╔╝
- ╚███╔╝
- ██╔██╗
+ ╚███╔╝
+ ██╔██╗
██╔╝ ██╗
╚═╝ ╚═╝
-
-
-
-
+===
+Yy
+---
██╗ ██╗
╚██╗ ██╔╝
- ╚████╔╝
- ╚██╔╝
- ██║
- ╚═╝
+ ╚████╔╝
+ ╚██╔╝
+ ██║
+ ╚═╝
+===
+Zz
+---
+███████╗
+╚══███╔╝
+ ███╔╝
+ ███╔╝
+███████╗
+╚══════╝
+===
+0
+---
+ ██████╗
+██╔═████╗
+██║██╔██║
+████╔╝██║
+╚██████╔╝
+ ╚═════╝
+===
+1
+---
+ ██╗
+███║
+╚██║
+ ██║
+ ██║
+ ╚═╝
+===
+2
+---
+██████╗
+╚════██╗
+ █████╔╝
+██╔═══╝
+███████╗
+╚══════╝
+===
+3
+---
+██████╗
+╚════██╗
+ █████╔╝
+ ╚═══██╗
+██████╔╝
+╚═════╝
+===
+4
+---
+██╗ ██╗
+██║ ██║
+███████║
+╚════██║
+ ██║
+ ╚═╝
+===
+5
+---
+███████╗
+██╔════╝
+███████╗
+╚════██║
+███████║
+╚══════╝
+===
+6
+---
+ ██████╗
+██╔════╝
+███████╗
+██╔═══██╗
+╚██████╔╝
+ ╚═════╝
+===
+7
+---
+███████╗
+╚════██║
+ ██╔╝
+ ██╔╝
+ ██║
+ ╚═╝
+===
+8
+---
+ █████╗
+██╔══██╗
+╚█████╔╝
+██╔══██╗
+╚█████╔╝
+ ╚════╝
+===
+9
+---
+ █████╗
+██╔══██╗
+╚██████║
+ ╚═══██║
+ █████╔╝
+ ╚════╝
+===
+!
+---
+██╗
+██║
+██║
+╚═╝
+██╗
+╚═╝
+===
+@
+---
+ ██████╗
+██╔═══██╗
+██║██╗██║
+██║██║██║
+╚█║████╔╝
+ ╚╝╚═══╝
+===
+#
+---
+ ██╗ ██╗
+████████╗
+╚██╔═██╔╝
+████████╗
+╚██╔═██╔╝
+ ╚═╝ ╚═╝
+===
+$
+---
+▄▄███▄▄·
+██╔════╝
+███████╗
+╚════██║
+███████║
+╚═▀▀▀══╝
+===
+%
+---
+██╗ ██╗
+╚═╝██╔╝
+ ██╔╝
+ ██╔╝
+██╔╝██╗
+╚═╝ ╚═╝
+===
+^
+---
+ ███╗
+██╔██╗
+╚═╝╚═╝
+
+
+
+===
+&
+---
+ ██╗
+ ██║
+████████╗
+██╔═██╔═╝
+██████║
+╚═════╝
+===
+*
+---
+
+▄ ██╗▄
+ ████╗
+▀╚██╔▀
+ ╚═╝
+
+===
+(
+---
+ ██╗
+██╔╝
+██║
+██║
+╚██╗
+ ╚═╝
+===
+)
+---
+██╗
+╚██╗
+ ██║
+ ██║
+██╔╝
+╚═╝
+===
+_
+---
███████╗
-╚══███╔╝
- ███╔╝
- ███╔╝
-███████╗
╚══════╝
+===
+,
+---
+
+
+
+
+▄█╗
+╚═╝
+===
+.
+---
+
+
+
+
+██╗
+╚═╝
+===
+<
+---
+ ██╗
+ ██╔╝
+██╔╝
+╚██╗
+ ╚██╗
+ ╚═╝
+===
+>
+---
+██╗
+╚██╗
+ ╚██╗
+ ██╔╝
+██╔╝
+╚═╝
+===
+?
+---
+██████╗
+╚════██╗
+ ▄███╔╝
+ ▀▀══╝
+ ██╗
+ ╚═╝
+===
+[
+---
+███╗
+██╔╝
+██║
+██║
+███╗
+╚══╝
+===
+]
+---
+███╗
+╚██║
+ ██║
+ ██║
+███║
+╚══╝
+===
diff --git a/main.go b/main.go
index e7aabc2..c9aebcf 100644
--- a/main.go
+++ b/main.go
@@ -32,14 +32,8 @@ func gen(w http.ResponseWriter, r *http.Request) {
return
}
- var asciiString string
+ asciiString := ASCIIRuneArray([]rune(val))
- runeArray := []rune(val)
-
- for i := 0; i < utf8.RuneCountInString(val); i++ {
- asciiString += ASCIICharacter(runeArray[i])
- }
-
- log15.Info("writing result", "result", asciiString)
- w.Write([]byte(asciiString))
+ log15.Info("writing result")
+ w.Write([]byte("<html><body style='text-align:center;background:#222;color:#ccc;'><pre><code>" + asciiString + "</code></pre></body></html>"))
}