• Re: LAB value - decimal or integer

# LAB value - decimal or integer

Community Beginner ,
Apr 04, 2022 Apr 04, 2022

Copied

Hi, I noticed that you can't set an LAB colors to decimal values, but to my big surprise, when you read the LAB values with an illustrator script, it will give you the exact decimal value.

First, I wish that illustrator would support LAB with decimal point for much better accuracy.

Secondly, in the current situation, I want to read the L value, A and B of a swatch I have. using the code below, I will get a value of -15.67 for example, which I will need to round if I want illustrator to read it.

Do you have an idea how can I round it to the value of the document?

For example, if B value is -15.67, illustrator will show the swatch's B value as -15 and not -16. Therefore I need to round it using Math.ceil , and if it was a positive number, Math.floor.

I can do an if statemant that will do the proper rounding if value is above 0 or below 0, but what if it's between -1 and 1?  The swatch might show 0 but the code will say it's -0.6 or 0.6 and I wouldn't know what rounding command is needed.

The code I use:

`````` var destColorSpace = ImageColorSpace["LAB"];
var outputColors = app.convertSampleColor(
sourceSpace,
colorComponents,
destColorSpace,
ColorConvertPurpose.previewpurpose
);
var l = Math.round(outputColors[0]), // grabs l value
a = Math.floor(outputColors[1]), // grabs a value - rounds down for example
b = outputColors[2]; // grabs b value - without rounding

TOPICS
Bug , Feature request , Scripting

Views

105

Likes

Report

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

Copied

I get -16 reading a lab value of -15.67

can you post the exact process you're following to try to replicate it?

Likes

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 Beginner ,
Apr 22, 2022 Apr 22, 2022

Copied

Try many more swatches with different color combinations.

I had a case of 15.67 for example showing up in Illustrator as 15 or 14 instead of 16.

I can't post the exact process or file, as it is protected data of a company.

Likes

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 Beginner ,
Apr 22, 2022 Apr 22, 2022

Copied

LATEST