ColorSampler
Represents a ColorSampler object in the Photoshop DOM.
ColorSamplers are created through the ColorSamplers collection via the ColorSamplers.add method:
Copied to your clipboardconst app = require("photoshop").app;app.activeDocument.colorSamplers.add({x: 100, y: 100});
Properties such as color
, position
and parent
document can be then accessed on the ColorSampler instance:
Copied to your clipboardlet cs = app.activeDocument.colorSamplers[0];console.log(cs.position); // {x: 100, y: 100}console.log(cs.color.rgb); // SolidColor {red: 0, green: 255, blue: 0}console.log(cs.parent); // Document
An existing ColorSampler instance can be moved to a different position:
Copied to your clipboardcs.move({x: 200, y: 200});console.log(cs.position); // {x: 200, y: 200}
Or removed altogether from the document:
Copied to your clipboardcs.remove();console.log(app.activeDocument.colorSamplers.length); // 0
Properties
Name | Type | Access | Min Version | Description |
---|---|---|---|---|
color | R | 24.0 | The color reading of this ColorSampler in its current position. | |
docId | number | R | 24.0 | The ID of the Document of this ColorSampler. |
parent | R | 24.0 | Owner document of this ColorSampler. | |
position | object | R | 24.0 | The position of this ColorSampler. |
typename | string | R | 24.0 | The class name of the referenced object: "ColorSampler". |
Methods
move
24.0void
Moves the ColorSampler object to the given position
Parameters
Name | Type | Description |
---|---|---|
position | object | Object literal with target coordinates in pixels {x: number, y: number} . |
position.x | number | - |
position.y | number | - |
remove
24.0void
Deletes the given ColorSampler object.