• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How we match two pathItems have same fillColor using Extendscript?

Explorer ,
Jan 19, 2021 Jan 19, 2021

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.

TOPICS
Scripting

Views

228

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Jan 19, 2021 Jan 19, 2021

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!

Votes

Translate

Translate
Adobe
Valorous Hero ,
Jan 19, 2021 Jan 19, 2021

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

LATEST

Thank you so much for timely helps. It works.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines