Edit in GitHubLog an issue

Solid Color

Represents a color, and allows for mapping into all available Photoshop color models.

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:

Copied to your clipboard
1const red = new SolidColor();
2red.rgb.red = 255;
3red.rgb.green = 0;
4red.rgb.blue = 0;
5
6app.foregroundColor = red;

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

Copied to your clipboard
1const c = new SolidColor();
2console.log(c.model); // By default, this will be ColorModel.RGB
3
4c.cmyk.cyan = 50; // Photoshop will convert the color to CMYK using Edit > Color Settings data
5console.log(c.model); // Now, the model will be ColorModel.CMYK
6
7c.rgb.green = 128; // Model will change back to ColorModel.RGB

Properties

名称类型访问最低版本描述
cmykCMYKColorR W23.0The color's representation in CMYK color space.
grayGrayColorR W23.0The color's representation in grayscale.
hsbHSBColorR W23.0The color's representation in HSB color space.
labLabColorR W23.0The color's representation in LAB color space.
nearestWebColorRGBColorR23.0The color's nearest match within the 216 web-safe colors.
rgbRGBColorR W23.0The color's representation in RGB color space.

Methods

isEqual

23.0

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

名称类型
colorSolidColor
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2023 Adobe. All rights reserved.