File: MoveSelection.txt

package info (click to toggle)
skyview 3.5.5%2Brepack-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,216 kB
  • sloc: java: 29,127; perl: 303; xml: 63; makefile: 19; sh: 1
file content (40 lines) | stat: -rw-r--r-- 1,245 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  // 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<xCoordinates.length; i++) {
              xCoordinates[i] += dx;
              yCoordinates[i] += dy;
          }
          makeSelection(selectionType, xCoordinates, yCoordinates);          
      }
  }