var k57 = 180/PI, turtleX = newArray(2000), turtleY = newArray(2000), verticesX = newArray(2000), verticesY = newArray(2000), turtlePhi, tPtr, vtxPtr, ; macro "Make Waves [F1]" { newImage("scratch", "8-bit Ramp", 700, 500, 1); run("Remove Overlay"); step = 10; //length of a step in pixels nSteps = 6;// dPhi = 8; //degrees between 2 steps cycles = 2; yStart = 100; yOffset = 80; for (waves = 0; waves < 4; waves++){ turtleInit(20, yStart, 0);//starting point and angle for (kk =0; kk 0 && index <= tPtr && tPtr>=3){ for (jj= index; jj= 360) turtlePhi -= 360; if (rad == 0) return; dx = rad * cos(turtlePhi/k57); dy = -rad * sin(turtlePhi/k57); newX = turtleX[tPtr] + dx; newY = turtleY[tPtr] + dy; tPtr++; turtleX[tPtr] = newX; turtleY[tPtr] = newY; } function turtlePath(start, stop){ //returns the path length between start and stop vertex if (start < 0) start = tPtr + start + 1; if (stop < 0) stop = tPtr + stop + 1; if (start > tPtr || stop > tPtr) return 0; len = 0; for (jj=minOf(start, stop); jj tPtr-1 || index < 0) return NaN; dx = (turtleX[index + 1] - turtleX[index]); dy = -(turtleY[index + 1] - turtleY[index]); return k57 * atan2(dy, dx); } function turtleAim(index, dPhi){ //changes current turtle direction to aim at a former vertex //defined by index. //No new vertex is added. //negative index: count from stack top backwards //if distance was zero, phi from aimed point is used as if (index < 0) index = tPtr + index +1; if (index >= tPtr || index < 0) exit("Turtle range error"); dx = -(turtleX[tPtr] - turtleX[index]); dy = (turtleY[tPtr] - turtleY[index]); if (dx == 0 && dy == 0) newPhi = turtlePhi;//[index]); else newPhi = k57 * atan2(dy, dx); turtlePhi = newPhi + dPhi; }