Copy link to clipboard
Copied
Hi All,
I have two path items in a document and the CMYK color filled.
Now I need to match programmatically using if condition, that path item having with CMYK (c:100, m=0, y=100, k=0) values.
Kindly help me to achieve this using extendscript.
Thanks.
This is a slow process if you have hundreds of paths, but essentially you can grab a fill color from a path with clr_1 = pathItem.fillColor and then compare clr_1.cyan != clr_2.cyan.
However there can be javascript mathematical rounding artifacts which may put a decimal and a bunch of numbers afterwards - for this reason if it becomes an issue, you can use Math.round(clr_1.cyan) != Math.round(clr_2.cyan) and so on. When you compare all the 4 cmyk colors and all are true, you have the same color!
Copy link to clipboard
Copied
This is a slow process if you have hundreds of paths, but essentially you can grab a fill color from a path with clr_1 = pathItem.fillColor and then compare clr_1.cyan != clr_2.cyan.
However there can be javascript mathematical rounding artifacts which may put a decimal and a bunch of numbers afterwards - for this reason if it becomes an issue, you can use Math.round(clr_1.cyan) != Math.round(clr_2.cyan) and so on. When you compare all the 4 cmyk colors and all are true, you have the same color!
Copy link to clipboard
Copied
Thank you so much for timely helps. It works.