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

Round Color Values in multiples of 10 [edited]

New Here ,
May 14, 2019 May 14, 2019

I want a script or a way When I have more colors CMYK If (K=1% or 2% or 3% or 4% or 5% convert to K=0% ) & If (K=6% or 7% or 8% or 9%  convert to K=10%)  Be part of the color and apply the theory to all colors C or M or Y or K

Example:

I have 2 color

Red:

C:5%

M:100%

Y:100%

K:5%

Green:

C:100%

M:6%

Y:100%

K:6%

Convert to ---

Red:

C:0%

M:100%

Y:100%

K:0%

Green:

C:100%

M:10%

Y:100%

K:10%

Note without prejudice to other values.

Applies to many colors

How ?????!

Message was edited by: carlos canto, title edited for clarity

TOPICS
Scripting
515
Translate
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
Adobe
Contributor ,
May 16, 2019 May 16, 2019

Here is the sample code to help you in your work

function round(val) {

return (Math.round(val / 10) * 10);

}

function main() {

var redColor = app.activeDocument.swatches.getByName('CMYK Red');   // make sure CMYK Red swatch exists in the document, and change it for different color.

redColor.color.cyan = round(Math.round(redColor.color.cyan)-1);

redColor.color.magenta = round(Math.round(redColor.color.magenta)-1);

redColor.color.yellow = round(Math.round(redColor.color.yellow)-1);

redColor.color.black = round(Math.round(redColor.color.black)-1);

}

main();

Hope this helps you.

Translate
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
New Here ,
May 16, 2019 May 16, 2019

Thank you

  The script does not work

I would like to have a script for all the colors in the design

Translate
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
Contributor ,
May 16, 2019 May 16, 2019

This is quite easy, you have to run this code in just for loop for all swatches exists in the document. Here is an example.

function round(val) {

return (Math.round(val / 10) * 10);

}

function main() {

var doc = app.activeDocument;

for (var i = 0; i < doc.swatches.length; i++) {

var swatch = doc.swatches;

swatch.color.cyan = round(Math.round(swatch.color.cyan) - 1);

swatch.color.magenta = round(Math.round(swatch.color.magenta) - 1);

swatch.color.yellow = round(Math.round(swatch.color.yellow) - 1);

swatch.color.black = round(Math.round(swatch.color.black) - 1);

}

}

main();

Translate
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
New Here ,
May 18, 2019 May 18, 2019

Thank you

But not working for all colors

Please explain video or pictures please

Translate
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
Contributor ,
May 20, 2019 May 20, 2019

Could you please specify what type of colors are you using in the document? May be your document have RGB or spot colors. If you can share the document then I may modify the script and also share the video or picture.

Translate
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
New Here ,
May 24, 2019 May 24, 2019

https://we.tl/t-335LHHOk8z

vector image - CMYK

Translate
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
New Here ,
May 24, 2019 May 24, 2019
LATEST

thank you work Script

but I need colors CMYK - Global

Translate
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