mirror of
https://github.com/1j01/textual-paint.git
synced 2025-01-05 05:33:28 +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:
|
def big_ch(self, ch: str, x: int, y: int) -> str:
|
||||||
"""Return a character part of a meta-glyph."""
|
"""Return a character part of a meta-glyph."""
|
||||||
if ch == " ":
|
match ch:
|
||||||
return " "
|
case " ":
|
||||||
if ch == "█":
|
|
||||||
return "█"
|
|
||||||
if ch == "▄":
|
|
||||||
if y < self.magnification // 2:
|
|
||||||
return " "
|
return " "
|
||||||
else:
|
case "█":
|
||||||
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:
|
|
||||||
return "█"
|
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.
|
# Fall back to showing the character for a single cell.
|
||||||
# if x == 0 and y == 0:
|
# if x == 0 and y == 0:
|
||||||
if x == self.magnification // 2 and y == self.magnification // 2:
|
if x == self.magnification // 2 and y == self.magnification // 2:
|
||||||
|
Loading…
Reference in New Issue
Block a user