Add character cell diagonals to box_chars

This commit is contained in:
Kovid Goyal 2020-09-03 13:51:54 +05:30
parent 9d3a9e9d1e
commit d7a6ceb3a6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 40 additions and 1 deletions

View File

@ -601,6 +601,7 @@ START_ALLOW_CASE_RANGE
case 0xe0bc: //  case 0xe0bc: // 
case 0xe0be: //  case 0xe0be: // 
case 0x1fb00 ... 0x1fb8b: // symbols for legacy computing case 0x1fb00 ... 0x1fb8b: // symbols for legacy computing
case 0x1fba0 ... 0x1fbae:
return BOX_FONT; return BOX_FONT;
default: default:
ans = in_symbol_maps(fg, cpu_cell->ch); ans = in_symbol_maps(fg, cpu_cell->ch);
@ -639,7 +640,9 @@ START_ALLOW_CASE_RANGE
case 0xe0b0 ... 0xe0d4: case 0xe0b0 ... 0xe0d4:
return 0xa0 + ch - 0xe0b0; // IDs from 0xa0 to 0xc4 return 0xa0 + ch - 0xe0b0; // IDs from 0xa0 to 0xc4
case 0x1fb00 ... 0x1fb8b: case 0x1fb00 ... 0x1fb8b:
return 0xc5 + ch - 0x1fb00; return 0xc5 + ch - 0x1fb00; // IDs from 0xc5 to 0x150
case 0x1fba0 ... 0x1fbae:
return 0x151 + ch - 0x1fba0;
default: default:
return 0xffff; return 0xffff;
} }

View File

@ -303,6 +303,26 @@ def half_cross_line(buf: BufType, width: int, height: int, which: str = 'tl', le
thick_line(buf, width, height, thickness_in_pixels, p1, p2) thick_line(buf, width, height, thickness_in_pixels, p1, p2)
@supersampled()
def mid_lines(buf: BufType, width: int, height: int, level: int = 1, pts: Iterable[str] = ('lt',)) -> None:
mid_x, mid_y = width // 2, height // 2
supersample_factor = getattr(buf, 'supersample_factor')
def pt_to_coords(p: str) -> Tuple[int, int]:
if p == 'l':
return 0, mid_y
if p == 't':
return mid_x, 0
if p == 'r':
return width - 1, mid_y
if p == 'b':
return mid_x, height - 1
for x in pts:
p1, p2 = map(pt_to_coords, x)
thick_line(buf, width, height, supersample_factor * thickness(level), p1, p2)
BezierFunc = Callable[[float], float] BezierFunc = Callable[[float], float]
@ -844,6 +864,22 @@ box_chars: Dict[str, List[Callable]] = {
'🮉': [p(eight_block, which=(3, 4, 5, 6, 7))], '🮉': [p(eight_block, which=(3, 4, 5, 6, 7))],
'🮊': [p(eight_block, which=(2, 3, 4, 5, 6, 7))], '🮊': [p(eight_block, which=(2, 3, 4, 5, 6, 7))],
'🮋': [p(eight_block, which=(1, 2, 3, 4, 5, 6, 7))], '🮋': [p(eight_block, which=(1, 2, 3, 4, 5, 6, 7))],
'🮠': [mid_lines],
'🮡': [p(mid_lines, pts=('tr',))],
'🮢': [p(mid_lines, pts=('lb',))],
'🮣': [p(mid_lines, pts=('br',))],
'🮤': [p(mid_lines, pts=('lt', 'lb'))],
'🮥': [p(mid_lines, pts=('rt', 'rb'))],
'🮦': [p(mid_lines, pts=('rb', 'lb'))],
'🮧': [p(mid_lines, pts=('rt', 'lt'))],
'🮨': [p(mid_lines, pts=('rb', 'lt'))],
'🮩': [p(mid_lines, pts=('lb', 'rt'))],
'🮪': [p(mid_lines, pts=('lb', 'rt', 'rb'))],
'🮫': [p(mid_lines, pts=('lb', 'lt', 'rb'))],
'🮬': [p(mid_lines, pts=('rt', 'lt', 'rb'))],
'🮭': [p(mid_lines, pts=('rt', 'lt', 'lb'))],
'🮮': [p(mid_lines, pts=('rt', 'rb', 'lt', 'lb'))],
} }
t, f = 1, 3 t, f = 1, 3