I'm trying to see if colours are the same in Photoshop scripting
RGB 0,128,60 == RGB 0,128,60 // true
RGB 0,128,60 == RGB 0,128,64 // false
Only most fancy javascript bits like every
and =>
as seen here don't work with Photoshop's ECMA script
This is what I have (based on Dogbert's example here), but I'm sure there's got to be a cleaner way. Apart from converting them to hex and then comparing them.
alert(identical_colours([[0,128,60], [0,128,60]])); // true
alert(identical_colours([[0,128,60], [0,128,64]])); // false
function identical_colours(arr)
{
for(var i = 0; i < arr.length - 1; i++)
{
if(arr[i][0] !== arr[i+1][0])
{
return false;
}
if(arr[i][1] !== arr[i+1][1])
{
return false;
}
if(arr[i][2] !== arr[i+1][2])
{
return false;
}
}
// True! Yay!
return true;
}