Invert QR code
This commit is contained in:
parent
86cbc977b0
commit
957e116305
2 changed files with 7 additions and 7 deletions
10
qr.go
10
qr.go
|
|
@ -33,7 +33,7 @@ func qrCodeToString(bits [][]bool, colorize bool) string {
|
||||||
s := ""
|
s := ""
|
||||||
for y := -1; y < len(bits); y += 2 {
|
for y := -1; y < len(bits); y += 2 {
|
||||||
if colorize {
|
if colorize {
|
||||||
s += TerminalForegroundWhite + TerminalBackgroundBlack
|
s += TerminalForegroundBlack + TerminalBackgroundWhite
|
||||||
}
|
}
|
||||||
for x := range bits[0] {
|
for x := range bits[0] {
|
||||||
upper := false
|
upper := false
|
||||||
|
|
@ -45,13 +45,13 @@ func qrCodeToString(bits [][]bool, colorize bool) string {
|
||||||
lower = bits[y+1][x]
|
lower = bits[y+1][x]
|
||||||
}
|
}
|
||||||
if upper && lower {
|
if upper && lower {
|
||||||
s += " "
|
s += "█"
|
||||||
} else if !upper && lower {
|
|
||||||
s += "▀"
|
|
||||||
} else if upper && !lower {
|
} else if upper && !lower {
|
||||||
|
s += "▀"
|
||||||
|
} else if !upper && lower {
|
||||||
s += "▄"
|
s += "▄"
|
||||||
} else {
|
} else {
|
||||||
s += "█"
|
s += " "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if colorize {
|
if colorize {
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TerminalForegroundWhite string = "\033[37m"
|
TerminalForegroundBlack string = "\033[30m"
|
||||||
TerminalForegroundReset string = "\033[39m"
|
TerminalForegroundReset string = "\033[39m"
|
||||||
TerminalBackgroundBlack string = "\033[40m"
|
TerminalBackgroundWhite string = "\033[47m"
|
||||||
TerminalBackgroundReset string = "\033[49m"
|
TerminalBackgroundReset string = "\033[49m"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue