Compare commits
1 Commits
ce9c8b1b6e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7c248d8ff9 |
@@ -12,12 +12,11 @@ pub fn render_ascii(qr: &QrCode, invert: bool) -> String {
|
|||||||
let mut result = String::new();
|
let mut result = String::new();
|
||||||
for y in 0..total {
|
for y in 0..total {
|
||||||
for x in 0..total {
|
for x in 0..total {
|
||||||
let mx = x.saturating_sub(margin);
|
let in_qr = x >= margin && x < margin + size && y >= margin && y < margin + size;
|
||||||
let my = y.saturating_sub(margin);
|
let is_dark = if in_qr {
|
||||||
let is_dark = if mx < size && my < size {
|
qr.modules()[y - margin][x - margin]
|
||||||
qr.modules()[my][mx]
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false // 静区始终为亮色
|
||||||
};
|
};
|
||||||
result.push_str(if is_dark { dark_char } else { light_char });
|
result.push_str(if is_dark { dark_char } else { light_char });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user