mirror of
https://github.com/ShinkoNet/Wplace-Overlay-Pro.git
synced 2026-05-17 14:12: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;
|
let index = 0;
|
||||||
for (let i = 0; i < ALL_COLORS.length; i++) {
|
for (let i = 0; i < ALL_COLORS.length; i++) {
|
||||||
const color = ALL_COLORS[i];
|
const color = ALL_COLORS[i];
|
||||||
const distance = Math.sqrt(
|
const distance =
|
||||||
Math.pow(r - color[0], 2) +
|
Math.pow(r - color[0], 2) +
|
||||||
Math.pow(g - color[1], 2) +
|
Math.pow(g - color[1], 2) +
|
||||||
Math.pow(b - color[2], 2)
|
Math.pow(b - color[2], 2);
|
||||||
);
|
|
||||||
if (distance < minDistance) {
|
if (distance < minDistance) {
|
||||||
minDistance = distance;
|
minDistance = distance;
|
||||||
index = i;
|
index = i;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue