Skip to content

Instantly share code, notes, and snippets.

@MarshySwamp
Created January 10, 2022 03:33
Show Gist options
  • Save MarshySwamp/451f60096079084b818d693d8cf09547 to your computer and use it in GitHub Desktop.
Save MarshySwamp/451f60096079084b818d693d8cf09547 to your computer and use it in GitHub Desktop.
An elliptical version of the standard rectangular select all command, it obviously does not select all as it is an ellipse, but you get the idea...
ellipticalSelectAll(0, 0, app.activeDocument.height.value, app.activeDocument.width.value, true);
function ellipticalSelectAll(top, left, bottom, right, antiAlias) {
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
reference.putProperty( s2t( "channel" ), s2t( "selection" ));
descriptor.putReference( s2t( "null" ), reference );
descriptor2.putUnitDouble( s2t( "top" ), s2t( "pixelsUnit" ), top );
descriptor2.putUnitDouble( s2t( "left" ), s2t( "pixelsUnit" ), left );
descriptor2.putUnitDouble( s2t( "bottom" ), s2t( "pixelsUnit" ), bottom );
descriptor2.putUnitDouble( s2t( "right" ), s2t( "pixelsUnit" ), right );
descriptor.putObject( s2t( "to" ), s2t( "ellipse" ), descriptor2 );
descriptor.putBoolean( s2t( "antiAlias" ), antiAlias );
executeAction( s2t( "set" ), descriptor, DialogModes.NO );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment