forked from hkc/cc-stuff
1
0
Fork 0

Optimized it a bit more

This commit is contained in:
Casey 2024-01-21 03:51:57 +03:00
parent e61774d4dd
commit 1e4fa997c0
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 2 additions and 1 deletions

View File

@ -55,7 +55,7 @@ class Converter:
brightest_i, brightest_l = 0, 0 brightest_i, brightest_l = 0, 0
darkest_i, darkest_l = 0, 768 darkest_i, darkest_l = 0, 768
for oy, line in enumerate(self.PIX_BITS): for oy, line in enumerate(self.PIX_BITS):
for ox, bit in enumerate(line): for ox in range(len(line)):
pix = self._imgdata[x + ox, y + oy] pix = self._imgdata[x + ox, y + oy]
brightness = self._brightness(pix) brightness = self._brightness(pix)
if brightness > brightest_l: if brightness > brightest_l:
@ -64,6 +64,7 @@ class Converter:
darkest_l, darkest_i = brightness, pix darkest_l, darkest_i = brightness, pix
return darkest_i, brightest_i return darkest_i, brightest_i
@lru_cache()
def _is_darker(self, bg: int, fg: int, c: int) -> bool: def _is_darker(self, bg: int, fg: int, c: int) -> bool:
return self._distance(bg, c) < self._distance(fg, c) return self._distance(bg, c) < self._distance(fg, c)