All Downloads are FREE. Search and download functionalities are using the official Maven repository.

macros.MoveSelection.txt Maven / Gradle / Ivy

Go to download

ImageJ is an open source Java image processing program inspired by NIH Image for the Macintosh.

There is a newer version: 1.54m
Show newest version
  // 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 - 2024 Weber Informatics LLC | Privacy Policy