Skip to content

Instantly share code, notes, and snippets.

@juliend2
Created September 21, 2010 01:42
Show Gist options
  • Save juliend2/589030 to your computer and use it in GitHub Desktop.
Save juliend2/589030 to your computer and use it in GitHub Desktop.
/*
Expanding color pixels on the current (and only loaded image)
*/
var doc = app.documents[0];
doc.colorSamplers.removeAll(); // otherwise it will create an error if there is already a colorSampler on this point
var offset = 4;
for (var w=0; w < doc.width; w+=offset) {
for (var h=0; h < doc.height; h+=offset) {
try {
doc.colorSamplers.removeAll();
var cSampler = doc.colorSamplers.add([w+1,h+1]);
var color = cSampler.color;
doc.selection.select([
[w,h],
[w+offset,h],
[w+offset, h+offset],
[w,h+offset]
]);
doc.selection.fill(color);
} catch (e){}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment