-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
41 lines (35 loc) · 719 Bytes
/
main.go
File metadata and controls
41 lines (35 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"image"
"image/png"
"os"
"strings"
"github.com/ejuju/bloc/pkg/bloc"
)
func main() {
txt := ""
if len(os.Args) >= 2 {
txt = strings.Join(os.Args[1:], "\n")
} else {
txt = "" +
"Pack my box with five dozen liquor jugs.\n" +
"Waltz, bad nymph, for quick jigs vex.\n" +
"0123456789\n" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ\n" +
"abcdefghijklmnopqrstuvwxyz\n" +
"!\"#$%&'()*+,-./\n" +
":;<=>?@\n" +
"[\\]^_`\n" +
"{|}~"
}
f, err := os.OpenFile("tmp/bloc.png", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
panic(err)
}
defer f.Close()
img := bloc.Image(txt, image.White, image.Black)
err = png.Encode(f, img)
if err != nil {
panic(err)
}
}