Skip to main content
Participant
July 30, 2011
Answered

JavaScript,sampling,RGB COLOR

  • July 30, 2011
  • 1 reply
  • 1079 views

How to get the coordinates of one pixel of the sampling point RGB color?


Example, the figure for the RGB value sampling tool:

This topic has been closed for replies.
Correct answer Muppet Mark

#target photoshop var doc = app.activeDocument, samps = doc.colorSamplers; for ( var i = 0; i < samps.length; i++ ) {            var r = Math.round( samps.color.rgb.red ),      g = Math.round( samps.color.rgb.green ),      b = Math.round( samps.color.rgb.blue );      alert( 'R'+r+' G'+g+' B'+b );       } alert ( samps[1].position );

1 reply

Muppet MarkCorrect answer
Inspiring
July 30, 2011

#target photoshop var doc = app.activeDocument, samps = doc.colorSamplers; for ( var i = 0; i < samps.length; i++ ) {            var r = Math.round( samps.color.rgb.red ),      g = Math.round( samps.color.rgb.green ),      b = Math.round( samps.color.rgb.blue );      alert( 'R'+r+' G'+g+' B'+b );       } alert ( samps[1].position );