function configureTool() { theTool = fl.tools.activeTool; theTool.setToolName("Spiral Tool 2"); theTool.setIcon("spiral2.png"); theTool.setMenuString("Spiral Tool 2"); theTool.setToolTip("Spiral Tool 2"); theTool.setOptionsFile( "spiral2.xml" ); }; //--------------------- function activate() { theTool= fl.tools.activeTool; accel = theTool.accel; lgt = theTool.lgt; radius=theTool.radius; manualAccel = theTool.manualAccel; manualLgt = theTool.manualLgt; manualRadius=theTool.manualRadius; rotat = theTool.rotat; } function notifySettingsChanged() { theTool= fl.tools.activeTool; accel = theTool.accel; lgt = theTool.lgt; radius=theTool.radius; manualAccel = theTool.manualAccel; manualLgt = theTool.manualLgt; manualRadius=theTool.manualRadius; rotat = theTool.rotat; } //--------------------- function transformPoint( pt, mat ) { var x = pt.x * mat.a + pt.y * mat.c + mat.tx; var y = pt.x * mat.b + pt.y * mat.d + mat.ty; pt.x = x; pt.y = y; } //fix dots coords in a circle-------- function xcoord(r, theta, cx) { return r*Math.cos(theta)+cx; } function ycoord(r, theta, cy) { return r*Math.sin(theta)+cy; } //---------------------------- function mouseDown() { fl.drawingLayer.beginDraw(); penDown = fl.tools.penDownLoc; transformPoint(penDown, fl.getDocumentDOM().viewMatrix); penDown = fl.tools.snapPoint(penDown); Sw=fl.getDocumentDOM().width; Sh=fl.getDocumentDOM().height; } //-------------------------- function mouseMove() { if(fl.tools.mouseIsDown){ danger=0; pen = fl.tools.penLoc; transformPoint(pen, fl.getDocumentDOM().viewMatrix); pen = fl.tools.snapPoint(pen); w = pen.x - penDown.x; h = pen.y - penDown.y; ang = Math.atan2(h, w); if(manualAccel){ accel = 1+Math.abs(ang)/Math.PI; } dist = Math.sqrt(w*w+h*h); if(manualLgt){ lgt = dist/accel; } //---------------- angle=rotat*Math.PI/180; dx = penDown.x; dy = penDown.y; if(manualRadius){ keyDown(); } r1 = radius; //--------------- fl.drawingLayer.beginFrame(); the_drawL = fl.drawingLayer; the_path=the_drawL.newPath(); //------------------------ for (k=1; k-200) && (yc-200)){ the_path.addCurve(x1,y1,xc,yc,x2,y2); }else{ danger=1; break; } } if(danger){ break; } } the_drawL.drawPath(the_path); fl.drawingLayer.endFrame(); } } //-------------------------------- function mouseUp() { fl.drawingLayer.endDraw(); the_path.makeShape(); } //-------------------------------- function keyDown() { switch(fl.tools.getKeyDown()){ case(38): radius= Math.min(radius+0.1,20); break; case(40): radius= Math.max(radius-0.1,0.1); break; } }