Copy link to clipboard
Copied
Dear all
I tried to add a LabColor with an Illustrator script.
function addLabColorToSwatch(L,a,b,swatchName){
var color = new LabColor();
color.l = L;
color.a = a;
color.b = b;
var swatchgroup = app.activeDocument.swatchGroups.add();
swatchgroup.name = "test swatchgroup from jsx script";
var swatch = app.activeDocument.swatches.add();
swatch.name = swatchName;
swatch.color = color;
swatchgroup.addSwatch(swatch);
return true;
}
addLabColorToSwatch(1,2,3,"test");
The script crashes on the Line 'swatch.color = color;' with "Error 1202: Not implemented"
This seems to a bug. I allready filed it. I'm asking if anybody has a workaround.
Thank you very much
best regards,
Alexander
PS: Original discussion: http://forums.adobe.com/message/4986457#4986457
Copy link to clipboard
Copied
you can add it as a spot
function addLabColorToSwatch(L,a,b,swatchName){
var color = new LabColor();
color.l = L;
color.a = a;
color.b = b;
var swatchgroup = app.activeDocument.swatchGroups.add();
swatchgroup.name = "test swatchgroup from jsx script";
var newSpot = app.activeDocument.spots.add();
newSpot.name = swatchName;
newSpot.colorType = ColorModel.SPOT;
newSpot.spotKind = SpotColorKind.SPOTLAB;
newSpot.color = color;
var newSpotColor = new SpotColor();
newSpotColor.spot = newSpot;
swatchgroup.addSpot(newSpot);
return true;
}
addLabColorToSwatch(72,-38,52,"test");
Copy link to clipboard
Copied
That's right. Only a spot color can be LAB. The same in the UI.
Copy link to clipboard
Copied
@CarlosCanto:
I know one can add spot colors based on Lab. But I would also like to add normal Process colors based on Lab values.
@pixxxel schubser
On the UI:
Go to Swatches. Add a new Swatch. Choose 'Process Color' and choose Color Mode 'Lab'. So you have added a swatch base on Lab values. That's what a try to do in code.
So basicaly I want to to add a 'Process Color' based on Lab Values.
Thanks
Copy link to clipboard
Copied
And have you looked at…
Array of number convertSampleColor (sourceColorSpace: ImageColorSpace, sourceColor: Array of number, destColorSpace: ImageColorSpace, colorConvertPurpose: ColorConvertPurpose[, sourceHasAlpha:bool=false][, destHasAlpha: bool=false])
Converts a sample-component color from one color space to another.
Parameter | Type | Description |
---|---|---|
sourceColorSpace | ImageColorSpace: ImageColorSpace.GrayScale ImageColorSpace.RGB ImageColorSpace.CMYK ImageColorSpace.LAB ImageColorSpace.Separation ImageColorSpace.DeviceN ImageColorSpace.Indexed | The source color space. |
sourceColor | Array of number | The color to convert, an array of color components. First location of the array should contain alpha if source-has-alpha is true. |
destColorSpace | ImageColorSpace: ImageColorSpace.GrayScale ImageColorSpace.RGB ImageColorSpace.CMYK ImageColorSpace.LAB ImageColorSpace.Separation ImageColorSpace.DeviceN ImageColorSpace.Indexed | The destination color space. |
colorConvertPurpose | ColorConvertPurpose: ColorConvertPurpose.defaultpurpose ColorConvertPurpose.previewpurpose ColorConvertPurpose.exportpurpose ColorConvertPurpose.dummypurpose | The parameter which passes the purpose of conversion. |
sourceHasAlpha | bool | True if alpha channel is present in source color. (default: false) (Optional) |
destHasAlpha | bool | True if alpha channel is present in destination color. (default: false) (Optional) |
Copy link to clipboard
Copied
Process colors added on the UI based on Lab will become spot colors.
So for Process color based on Lab values, use convertSampleColor as mentioned by Muppet Mark, will do the thing.
But generaly of course Lab colors are spot colors.
Thank you all for your answers
Find more inspiration, events, and resources on the new Adobe Community
Explore Now