MCPcopy Create free account
hub / github.com/PyQt5/PyQtClient / nearest

Method nearest

Utils/ColorThief.py:378–391  ·  view source on GitHub ↗
(self, color)

Source from the content-addressed store, hash-verified

376 return self.vboxes.size()
377
378 def nearest(self, color):
379 d1 = None
380 p_color = None
381 for i in range(self.vboxes.size()):
382 vbox = self.vboxes.peek(i)
383 d2 = math.sqrt(
384 math.pow(color[0] - vbox['color'][0], 2) +
385 math.pow(color[1] - vbox['color'][1], 2) +
386 math.pow(color[2] - vbox['color'][2], 2)
387 )
388 if d1 is None or d2 < d1:
389 d1 = d2
390 p_color = vbox['color']
391 return p_color
392
393 def map(self, color):
394 for i in range(self.vboxes.size()):

Callers 1

mapMethod · 0.95

Calls 2

peekMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected