How can I draw a rectangle?
I need to simulate drawing a rectangle with the Rectangle tool in a script. One way is to use the Script Listener and modify the code so I can pass the necessary variables. Is there a better solution? Thanks.
I need to simulate drawing a rectangle with the Rectangle tool in a script. One way is to use the Script Listener and modify the code so I can pass the necessary variables. Is there a better solution? Thanks.
You can draw a rectangle as follows.
#target photoshop;
app.bringToFront();
main();
function main(){
try{
app.displayDialogs = DialogModes.NO;
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
var Colour = new SolidColor;
Colour.rgb.hexValue = 'ff00ff';
app.documents.add();
activeDocument.selection.select([[10, 10], [494, 10], [494, 350], [10,350]], SelectionType.REPLACE, 0, false);
activeDocument.selection.stroke (Colour, 4, StrokeLocation.INSIDE,ColorBlendMode.NORMAL,100);
activeDocument.selection.deselect();
}catch(e){}
finally{
app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;
};
};
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.