
macros.MoveSelection.txt Maven / Gradle / Ivy
// Moves the selection left and down a specified distance in pixels.
xy = split(getArgument());
if (lengthOf(xy)!=2) {
dx = 10;
dy = 10;
} else {
dx = parseFloat(xy[0]);
if (isNaN(dx)) dx = 10;
dy = parseFloat(xy[1]);
if (isNaN(dy)) dy = 10;
}
getPixelSize(unit, pixelWidth, pixelHeight);
if (unit=="pixel") unit = "pixels";
dxc = dx*pixelWidth;
dyc = dy*pixelHeight;
Dialog.create("Move");
Dialog.addNumber("Delta_X ("+unit+"):", dxc);
Dialog.addNumber("Delta_Y ("+unit+"):", dyc);
Dialog.show();
dx = Dialog.getNumber()/pixelWidth;
dy = Dialog.getNumber()/pixelHeight;
moveSelection(dx, dy);
return toString(dx)+" "+toString(dy);
function moveSelection(dx, dy) {
getBoundingRect(x, y, width, height);
if (selectionType==0)
makeRectangle(x+dx, y+dy, width, height);
else if (selectionType==1)
makeOval(x+dx, y+dy, width, height);
else {
getSelectionCoordinates(xCoordinates, yCoordinates);
for (i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy