//func get_qr(t string) image.Image { func get_qr(t string) string { var q *qr.Code var e error q, e = qr.Encode(t, qr.L) if e != nil { fmt.Println(e) } fmt.Println(t) fmt.Print("QR Code Size (Pixels) = ") fmt.Println(q.Size) q.Scale = *mult // return q.Image() return string(q.PNG()) }
func ascii(code *qr.Code) string { var buf bytes.Buffer buf.WriteString("\n") for row := 0; row < code.Size; row++ { buf.WriteString(" ") for col := 0; col < code.Size; col++ { if code.Black(col, row) { buf.WriteString("#") } else { buf.WriteString(" ") } } buf.WriteString("\n") } buf.WriteString("\n") return buf.String() }
func terminal(code *qr.Code) string { var buf bytes.Buffer line := strings.Repeat(white, code.Size+2) buf.WriteString(line + "\n") for row := 0; row < code.Size; row++ { buf.WriteString(white) for col := 0; col < code.Size; col++ { if code.Black(col, row) { buf.WriteString(black) } else { buf.WriteString(white) } } buf.WriteString(white + "\n") } buf.WriteString(line + "\n") return buf.String() }