mirror of
https://github.com/ShinkoNet/Wplace-Overlay-Pro.git
synced 2026-05-07 21:00:47 +00:00
perf: remove unnecssary Math.sqrt for comparision in findClosestColorIndex
This commit is contained in:
parent
b8769ff619
commit
c4c7649c82
1 changed files with 2 additions and 3 deletions
|
|
@ -42,11 +42,10 @@ function findClosestColorIndex(r: number, g: number, b: number) {
|
|||
let index = 0;
|
||||
for (let i = 0; i < ALL_COLORS.length; i++) {
|
||||
const color = ALL_COLORS[i];
|
||||
const distance = Math.sqrt(
|
||||
const distance =
|
||||
Math.pow(r - color[0], 2) +
|
||||
Math.pow(g - color[1], 2) +
|
||||
Math.pow(b - color[2], 2)
|
||||
);
|
||||
Math.pow(b - color[2], 2);
|
||||
if (distance < minDistance) {
|
||||
minDistance = distance;
|
||||
index = i;
|
||||
|
|
|
|||
Loading…
Reference in a new issue