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 clipboard1const red = new SolidColor();2red.rgb.red = 255;3red.rgb.green = 0;4red.rgb.blue = 0;56app.foregroundColor = red;
To understand how color models change as you interact with a SolidColor object, please see example below:
Copied to your clipboard1const c = new SolidColor();2console.log(c.model); // By default, this will be ColorModel.RGB34c.cmyk.cyan = 50; // Photoshop will convert the color to CMYK using Edit > Color Settings data5console.log(c.model); // Now, the model will be ColorModel.CMYK67c.rgb.green = 128; // Model will change back to ColorModel.RGB
Properties
名称 | 类型 | 访问 | 最低版本 | 描述 |
---|---|---|---|---|
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. |
Methods
isEqual
23.0boolean
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
名称 | 类型 |
---|---|
color | SolidColor |