taxicab style color comparison
This commit is contained in:
10
main.js
10
main.js
@@ -19,3 +19,13 @@ function deRasterize(i, width){
|
|||||||
x: i % width
|
x: i % width
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function compareColors(c1,c2){ //compare two rgba color structs
|
||||||
|
//general basic distance nothing too special
|
||||||
|
|
||||||
|
let sum1 = c1.r + c1.g + c1.b + c1.a;
|
||||||
|
let sum2 = c2.r + c2.g + c2.b + c2.a;
|
||||||
|
|
||||||
|
if (Math.abs(sum1-sum2) < (tolerance*4)) {
|
||||||
|
return true;
|
||||||
|
} else return false;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user