Merge branch 'feat/undercurl-retina' of https://github.com/disrupted/kitty

This commit is contained in:
Kovid Goyal 2021-05-21 08:30:21 +05:30
commit c5afe4e745
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 21 additions and 9 deletions

View File

@ -59,6 +59,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- Add an option :option:`kitty @ get-text --add-wrap-markers` to add line wrap - Add an option :option:`kitty @ get-text --add-wrap-markers` to add line wrap
markers to the output (:pull:`3633`) markers to the output (:pull:`3633`)
- Improve rendering of curly underlines on HiDPI screens (:pull:`3637`)
- ssh kitten: Mimic behavior of ssh command line client more closely by - ssh kitten: Mimic behavior of ssh command line client more closely by
executing any command specified on the command line via the users' shell executing any command specified on the command line via the users' shell
just as ssh does (:iss:`3638`) just as ssh does (:iss:`3638`)

View File

@ -236,7 +236,15 @@ def add_dline(buf: ctypes.Array, cell_width: int, position: int, thickness: int,
def add_curl(buf: ctypes.Array, cell_width: int, position: int, thickness: int, cell_height: int) -> None: def add_curl(buf: ctypes.Array, cell_width: int, position: int, thickness: int, cell_height: int) -> None:
max_x, max_y = cell_width - 1, cell_height - 1 max_x, max_y = cell_width - 1, cell_height - 1
xfactor = 2.0 * pi / max_x xfactor = 2.0 * pi / max_x
half_height = max(thickness // 2, 1) thickness = max(1, thickness)
if thickness < 3:
half_height = thickness
thickness -= 1
elif thickness == 3:
half_height = thickness = 2
else:
half_height = thickness // 2
thickness -= 2
def add_intensity(x: int, y: int, val: int) -> None: def add_intensity(x: int, y: int, val: int) -> None:
y += position y += position
@ -244,20 +252,22 @@ def add_curl(buf: ctypes.Array, cell_width: int, position: int, thickness: int,
idx = cell_width * y + x idx = cell_width * y + x
buf[idx] = min(255, buf[idx] + val) buf[idx] = min(255, buf[idx] + val)
# Ensure all space at bottom of cell is used # Ensure curve doesn't exceed cell boundary at the bottom
if position + half_height < max_y: position += half_height * 2
position += max_y - (position + half_height)
if position + half_height > max_y: if position + half_height > max_y:
position -= position + half_height - max_y position = max_y - half_height
# Use the Wu antialias algorithm to draw the curve # Use the Wu antialias algorithm to draw the curve
# cosine waves always have slope <= 1 so are never steep # cosine waves always have slope <= 1 so are never steep
for x in range(cell_width): for x in range(cell_width):
y = half_height * cos(x * xfactor) y = half_height * cos(x * xfactor)
y1, y2 = floor(y), ceil(y) y1, y2 = floor(y - thickness), ceil(y)
i1 = int(255 * abs(y - y1)) i1 = int(255 * abs(y - floor(y)))
add_intensity(x, y1, 255 - i1) add_intensity(x, y1, 255 - i1) # upper bound
add_intensity(x, y2, i1) add_intensity(x, y2, i1) # lower bound
# fill between upper and lower bound
for t in range(1, thickness + 1):
add_intensity(x, y1 + t, 255)
def render_special( def render_special(