What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Reply to thread

Hey, here is fixed code ;)

[CODE=javascript]var doc = app.activeDocument;


//SAVE RULER UNITS

backupRuler = app.preferences.rulerUnits;


//SET RULERS TO PX

app.preferences.rulerUnits = Units.PIXELS;


//SET POSITION OF SAMPLE

var xPos = 5;

var yPos = 5;


//REMOVE EXISTING SAMPLES

app.activeDocument.colorSamplers.removeAll();


//SET NEW SAMPLE

var target = [xPos , yPos];

var sample = app.activeDocument.colorSamplers.add(target);


//GET COLORS FROM SAMPLE

var Color = sample.color;

var R = Math.ceil(Color.rgb.red);

var G = Math.ceil(Color.rgb.green);

var B = Math.ceil(Color.rgb.blue);


//REMOVE SAMPLE

app.activeDocument.colorSamplers.removeAll();


//SET NEW COLOR

var color = app.backgroundColor;

color.rgb.red = R;

color.rgb.green = G;

color.rgb.blue = B;


app.backgroundColor = color;


//RESTORE RULER SETTINGS

app.preferences.rulerUnits = backupRuler[/CODE]


What is our favorite program/app? (Hint - it begins and ends with the letter P)
Back
Top