// These macros demonstrate how to use the
// getSelectionCoordinates function.

macro "List XY Coordinates" {
     requires("1.30k");
     getSelectionCoordinates(x, y);
     for (i=0; i<x.length; i++)
         print(i+" "+x[i]+" "+y[i]);
}

macro "Plot Selection" {
     requires("1.30k");
     getSelectionCoordinates(x, y);
     type = selectionType();
     newImage("Outline", "8-bit white", getWidth, getWidth, 1);
     setColor(0); // black
     moveTo(x[0], y[0]);
     for (i=1; i<x.length; i++)
         lineTo(x[i], y[i]);
     if (type==2 || type==3)
        lineTo(x[0], y[0]);
}

macro "Test Speed" {
    start = getTime();
    count = 0;
    do {
        getSelectionCoordinates(x, y);
        count++;
     } while (getTime()<start+1000);
    print(count + " getSelectionCoordinates() calls per second");
}
