mirror of
https://github.com/1j01/textual-paint.git
synced 2025-01-02 20:04:36 +03:00
Refactor meta character mapping to use match
This commit is contained in:
parent
7cdb35a4ae
commit
74c4af1a5b
33
paint.py
33
paint.py
@ -798,30 +798,19 @@ class Canvas(Widget):
|
||||
|
||||
def big_ch(self, ch: str, x: int, y: int) -> str:
|
||||
"""Return a character part of a meta-glyph."""
|
||||
if ch == " ":
|
||||
match ch:
|
||||
case " ":
|
||||
return " "
|
||||
if ch == "█":
|
||||
return "█"
|
||||
if ch == "▄":
|
||||
if y < self.magnification // 2:
|
||||
return " "
|
||||
else:
|
||||
return "█"
|
||||
if ch == "▀":
|
||||
if y < self.magnification // 2:
|
||||
return "█"
|
||||
else:
|
||||
return " "
|
||||
if ch == "▌":
|
||||
if x < self.magnification // 2:
|
||||
return "█"
|
||||
else:
|
||||
return " "
|
||||
if ch == "▐":
|
||||
if x < self.magnification // 2:
|
||||
return " "
|
||||
else:
|
||||
case "█":
|
||||
return "█"
|
||||
case "▄":
|
||||
return "█" if y >= self.magnification // 2 else " "
|
||||
case "▀":
|
||||
return "█" if y < self.magnification // 2 else " "
|
||||
case "▌":
|
||||
return "█" if x < self.magnification // 2 else " "
|
||||
case "▐":
|
||||
return "█" if x >= self.magnification // 2 else " "
|
||||
# Fall back to showing the character for a single cell.
|
||||
# if x == 0 and y == 0:
|
||||
if x == self.magnification // 2 and y == self.magnification // 2:
|
||||
|
Loading…
Reference in New Issue
Block a user