Solid Color

Represents a color, and allows for mapping into all available Photoshop color models. Import SolidColor from the Photoshop's app object:

const SolidColor = require("photoshop").app.SolidColor;

When a property is accessed (either via read or write), the current color model of the SolidColor objects gets set to the space of the accessor. Photoshop internally converts the color across these color spaces using the Color Settings set by the user.

For example, to set the foreground color to red:

const SolidColor = require("photoshop").app.SolidColor;
const red = new SolidColor();
red.rgb.red = 255;
red.rgb.green = 0;
red.rgb.blue = 0;

app.foregroundColor = red;

To understand how color models change as you interact with a SolidColor object, please see example below:

const SolidColor = require("photoshop").app.SolidColor;
const c = new SolidColor();
console.log(c.base.typename); // By default, this will be "RGBColor"

c.cmyk.cyan = 50; // Photoshop will convert the color to CMYK using Edit > Color Settings data
console.log(c.base.typename); // Now, the typename will be "CMYKColor"

c.rgb.green = 128; // Typename will change back to "RGBColor"

Fixes in Photoshop 24.2:

Constructors

constructor

<span class="minversion" style="display: block; margin-bottom: -1em; margin-left: 36em; float:left; opacity:0.5;">23.0</span>

<br/> SolidColor

All colors default to pure white.

const SolidColor = require("photoshop").app.SolidColor;
const color = new SolidColor();

Parameters

Name
Type
Description
model?
ColorModel
Color model to start.

Properties

Name
Type
Access
Min Version
Description
cmyk
CMYKColor
R W
23.0
The color's representation in CMYK color space.
gray
GrayColor
R W
23.0
The color's representation in grayscale.
hsb
HSBColor
R W
23.0
The color's representation in HSB color space.
lab
LabColor
R W
23.0
The color's representation in LAB color space.
nearestWebColor
RGBColor
R
23.0
The color's nearest match within the 216 web-safe colors.
rgb
RGBColor
R W
23.0
The color's representation in RGB color space.
typename
string
R
24.2
The class name of the referenced object: "SolidColor".

Methods

isEqual

<span class="minversion" style="display: block; margin-bottom: -1em; margin-left: 36em; float:left; opacity:0.5;">23.0</span>

<br/> boolean

True if the SolidColor object is visually equivalent to the specified color.

Both colors are converted to Lab colorspace, and the sum of their normalized squared Euclidian distance in each space is averaged across the three then compared to a small constant (3.5e-6).

Due to differences in coverage by various color spaces and clamping, a color that is converted from RGB to CMYK and back may not be visually equal.

Parameters

Name
Type
color
SolidColor