Optimized it a bit more
This commit is contained in:
parent
e61774d4dd
commit
1e4fa997c0
|
@ -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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue