ColorSampler
Represents a ColorSampler object in the Photoshop DOM.
ColorSamplers are created through the ColorSamplers collection via the ColorSamplers.add method:
Copied to your clipboard1const app = require("photoshop").app;2app.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 clipboard1let cs = app.activeDocument.colorSamplers[0];2console.log(cs.position); // {x: 100, y: 100}3console.log(cs.color.rgb); // SolidColor {red: 0, green: 255, blue: 0}4console.log(cs.parent); // Document
An existing ColorSampler instance can be moved to a different position:
Copied to your clipboard1cs.move({x: 200, y: 200});2console.log(cs.position); // {x: 200, y: 200}
Or removed altogether from the document:
Copied to your clipboard1cs.remove();2console.log(app.activeDocument.colorSamplers.length); // 0
Properties
名称 | 类型 | 访问 | 最低版本 | 描述 |
---|---|---|---|---|
color | SolidColor | NoColor | 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 | Document | 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
名称 | 类型 | 描述 |
---|---|---|
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.