Last active
June 14, 2022 08:54
-
-
Save Potherca/40379ee258f82eaef6100fa5a9f46b20 to your computer and use it in GitHub Desktop.
Output an ASCII string as SVG string in Go using https://github.com/asciitosvg/asciitosvg -- Run live at: https://go.dev/play/p/t2TBmJ9Rpfl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/asciitosvg/asciitosvg" | |
) | |
const logo = ` .-------------------------. | |
| | | |
| .---.-. .-----. .-----. | | |
| | .-. | +--> | | <--+ | | |
| | '-' | | <--+ +--> | | | |
| '---'-' '-----' '-----' | | |
| ascii 2 svg | | |
| | | |
'-------------------------' | |
https://github.com/asciit | |
osvg | |
[1,0]: {"fill":"#88d","a2s:delref":1} | |
` | |
func main() { | |
input := []byte(logo) | |
font := "Consolas,Monaco,Anonymous Pro,Anonymous,Bitstream Sans Mono,monospace" // Font family to use | |
noBlur := false // Disable drop-shadow blur | |
scaleX := 9 // X grid scale in pixels | |
scaleY := 16 // Y grid scale in pixels | |
tabWidth := 8 // Tab width. | |
canvas, err := asciitosvg.NewCanvas(input, tabWidth, true) | |
if err == nil { | |
svg := asciitosvg.CanvasToSVG(canvas, noBlur, font, scaleX, scaleY) | |
fmt.Printf("%s\n", svg) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment