示例#1
0
文件: iqr.go 项目: uhu99/kurzware
//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())
}
示例#2
0
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()
}
示例#3
0
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()
}