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() }