Skip to content

Commit

Permalink
[lib,test] Updated use of BaseImage._renderer()
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymouX47 committed Jun 24, 2022
1 parent 69cd28a commit ee64cee
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
Empty file added specifier
Empty file.
16 changes: 7 additions & 9 deletions term_image/image/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,12 @@ def __format__(self, spec: str) -> str:
spec
)

return self._renderer(
lambda image: self._format_render(
self._render_image(image, alpha, **style_args),
h_align,
width,
v_align,
height,
)
return self._format_render(
self._renderer(self._render_image, alpha, **style_args),
h_align,
width,
v_align,
height,
)

def __iter__(self) -> ImageIterator:
Expand All @@ -232,7 +230,7 @@ def __repr__(self) -> str:
def __str__(self) -> str:
"""Renders the image with transparency enabled and without alignment"""
# Only the currently set frame is rendered for animated images
return self._renderer(lambda image: self._render_image(image, _ALPHA_THRESHOLD))
return self._renderer(self._render_image, _ALPHA_THRESHOLD)

# Properties

Expand Down
2 changes: 1 addition & 1 deletion tests/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TestRender:
trans.height = _size

def render_image(self, alpha):
return self.trans._renderer(lambda im: self.trans._render_image(im, alpha))
return self.trans._renderer(self.trans._render_image, alpha)

def test_size(self):
self.trans.scale = 1.0
Expand Down
8 changes: 2 additions & 6 deletions tests/test_iterm2.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,7 @@ class TestRenderLines:
trans.set_render_method(LINES)

def render_image(self, alpha=0.0, *, m=False, c=4):
return self.trans._renderer(
lambda im: self.trans._render_image(im, alpha, mix=m, compress=c)
)
return self.trans._renderer(self.trans._render_image, alpha, mix=m, compress=c)

@staticmethod
def _test_image_size(image, term="", jpeg=False):
Expand Down Expand Up @@ -486,9 +484,7 @@ class TestRenderWhole:
trans.set_render_method(WHOLE)

def render_image(self, alpha=0.0, *, m=False, c=4):
return self.trans._renderer(
lambda im: self.trans._render_image(im, alpha, mix=m, compress=c)
)
return self.trans._renderer(self.trans._render_image, alpha, mix=m, compress=c)

@staticmethod
def _test_image_size(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_kitty.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class TestRenderLines:

def render_image(self, alpha=0.0, *, z=0, m=False, c=4):
return self.trans._renderer(
lambda im: self.trans._render_image(im, alpha, z_index=z, mix=m, compress=c)
self.trans._render_image, alpha, z_index=z, mix=m, compress=c
)

def _test_image_size(self, image):
Expand Down Expand Up @@ -464,7 +464,7 @@ class TestRenderWhole:

def render_image(self, alpha=0.0, z=0, m=False, c=4):
return self.trans._renderer(
lambda im: self.trans._render_image(im, alpha, z_index=z, mix=m, compress=c)
self.trans._render_image, alpha, z_index=z, mix=m, compress=c
)

def _test_image_size(self, image):
Expand Down

0 comments on commit ee64cee

Please sign in to comment.