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(
var l = Math.round(outputColors), // grabs l value
a = Math.floor(outputColors), // grabs a value - rounds down for example
b = outputColors; // grabs b value - without rounding
alert(b) // output: -15.67