Edit in GitHubLog an issue

ColorSampler

Represents a ColorSampler object in the Photoshop DOM.

ColorSamplers are created through the ColorSamplers collection via the ColorSamplers.add method:

Copied to your clipboard
1const 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 clipboard
1let 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 clipboard
1cs.move({x: 200, y: 200});
2console.log(cs.position); // {x: 200, y: 200}

Or removed altogether from the document:

Copied to your clipboard
1cs.remove();
2console.log(app.activeDocument.colorSamplers.length); // 0

Properties

名称类型访问最低版本描述
colorSolidColor | NoColorR24.0The color reading of this ColorSampler in its current position.
docIdnumberR24.0The ID of the Document of this ColorSampler.
parentDocumentR24.0Owner document of this ColorSampler.
positionobjectR24.0The position of this ColorSampler.
typenamestringR24.0The class name of the referenced object: "ColorSampler".

Methods

move

24.0

void

Moves the ColorSampler object to the given position

Parameters

名称类型描述
positionobjectObject literal with target coordinates in pixels {x: number, y: number}.
position.xnumber-
position.ynumber-

remove

24.0

void

Deletes the given ColorSampler object.

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