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

Or removed altogether from the document:

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

Properties

NameTypeAccessMin VersionDescription
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.0

void

Moves the ColorSampler object to the given position

Parameters

NameTypeDescription
position
object
Object literal with target coordinates in pixels {x: number, y: number}.
position.x
number
-
position.y
number
-

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 © 2024 Adobe. All rights reserved.