In this example, we will show you how to use the CreativeEditor SDK’s CreativeEngine to manage spot colors in the editor
API.
Functions
findAllSpotColors(): string[]
Queries the names of currently set spot colors previously set with setSpotColorRGB
.
- Returns The names of set spot colors.
getSpotColorRGBA(name: string): RGBA
Queries the RGB representation set for a spot color. If the value of the queried spot color has not been set yet, returns the default RGB representation (of magenta). The alpha value is always 1.0.
name
: The name of a spot color.- Returns A result holding a float array of the four color components.
getSpotColorCMYK(name: string): CMYK
Queries the CMYK representation set for a spot color. If the value of the queried spot color has not been set yet, returns the default CMYK representation (of magenta).
name
: The name of a spot color.- Returns A result holding a float array of the four color components.
setSpotColorRGB(name: string, r: number, g: number, b: number): void
Sets the RGB representation of a spot color. Use this function to both create a new spot color or update an existing spot color.
name
: The name of a spot color.r
: The red color component in the range of 0 to 1.g
: The green color component in the range of 0 to 1.b
: The blue color component in the range of 0 to 1.
setSpotColorCMYK(name: string, c: number, m: number, y: number, k: number): void
Sets the CMYK representation of a spot color. Use this function to both create a new spot color or update an existing spot color.
name
: The name of a spot color.c
: The cyan color component in the range of 0 to 1.m
: The magenta color component in the range of 0 to 1.y
: The yellow color component in the range of 0 to 1.k
: The key color component in the range of 0 to 1.
removeSpotColor(name: string): void
Removes a spot color from the list of set spot colors.
name
: The name of a spot color.- Returns An empty result on success, an error otherwise.
Full Code
Here’s the full code:
// Create a spot color with an RGB color approximation.engine.editor.setSpotColorRGB('Red', 1.0, 0.0, 0.0);
// Create a spot color with a CMYK color approximation.// Add a CMYK approximation to the already defined 'Red' spot color.engine.editor.setSpotColorCMYK('Yellow', 0.0, 0.0, 1.0, 0.0);engine.editor.setSpotColorCMYK('Red', 0.0, 1.0, 1.0, 0.0);
// List all defined spot colors.engine.editor.findAllSpotColors(); // ['Red', 'Yellow']
// Retrieve the RGB color approximation for a defined color.// The alpha value will always be 1.0.const rgbaSpotRed = engine.editor.getSpotColorRGBA('Red');
// Retrieve the CMYK color approximation for a defined color.const cmykSpotRed = engine.editor.getSpotColorCMYK('Red');
// Retrieving the approximation of an undefined spot color returns magenta.const cmykSpotUnknown = engine.editor.getSpotColorCMYK('Unknown'); // Returns CMYK values for magenta.
// Removes a spot color from the list of defined spot colors.engine.editor.removeSpotColor('Red');