function BezierArrow( leftX,leftY,rightX,rightY,myWidth,myHeight )

/*****************************************************************

                       Draws a Bezier Arrow

  Kleanthis Economou - ekleanthis@hotmail.com  18/12/1999 09:57

  Width , Height are not calculated inside, incase we don't

  come here from a selection.

*****************************************************************/

{

   // First Point - p1

   var pX = leftX + (2/3)*myWidth;

   var pY = leftY;

   fw.getDocumentDOM().addNewSinglePointPath({x:pX, y:pY}, {x:pX, y:pY}, {x:pX, y:pY}, true);

   //Walk on the Arrow points

   for ( j=1; j<8; j++ ) {     switch (j) {       case 1:        // 2nd point        pX = rightX;     pY = rightY - (myHeight/2);     break;    case 2:     // 3rd Point     pX = rightX - (1/myTriangRef)*myWidth;     pY = rightY;     break;    case 3:     //4th Point     //pX the same     pY = rightY - (1/myTriangGap)*myHeight;     break;    case 4:     //5th Point     pX = leftX;     //pY the same     break;    case 5:     //6th Point     //pX the same     pY = leftY + (myHeight/myTriangGap);     break;    case 6:     //7th Point     pX = leftX + (2/myTriangRef)*myWidth;     //pY the same     break;    case 7:     //8th Point     pX = leftX + (2/myTriangRef)*myWidth;     pY = leftY;     break;      } // switch (i)      fw.getDocumentDOM().appendPointToPath(0, j, {x:pX, y:pY}, {x:pX, y:pY}, {x:pX, y:pY});    }  // for j    return this; }  // BezierArrow  // Change the values below to tweak the arrow that we get as a result //----------------------------------------------------------------------------------------------- // For the type of Arrow we make var myHeightRef = 2.5 //How the Height of the Arrow compares to the Width, Def: Height =Width/2.5         // If the user doesn't have a selection
var myTriangRef = 3 // How long will the triangle be: Def = 1/3 of the total width
var myTriangGap = 4 // How long the "ears" will be:  Def = 1/4 of the total Height
//-----------------------------------------------------------------------------------------------

//Check if we have a slelcetion
if ( fw.selection != null && fw.selection.length > 0 ) {

	// Remember the original selection.
	var origSel = fw.selection;

	// Create an array to hold the new selection.
	var newSel = new Array(origSel.length);

	// Loop through the Array.
	for (i in origSel) {
		var elemType = origSel[i].toString();

		// Verify that the selection is a path.
		if (elemType == "[object Path]") {

			// Select just one element in the original selection.
			fw.selection = [ origSel[i] ];

			// Get the attributes for the selection.
			var pathAttrs = origSel[i].pathAttributes;

			// Get the effects for the selection.
			var effects = origSel[i].effectList;

			// Get the opacity for the selection.
			var opacity = origSel[i].opacity

			// Get the selection size.
			var selectBounds = fw.getDocumentDOM().getSelectionBounds();
			var leftX = selectBounds.left;
			var leftY = selectBounds.top;
			var rightX = selectBounds.right;
			var rightY = selectBounds.bottom;

			// Width of each selection
			var myWidth = rightX - leftX;
			var myHeight = rightY - leftY;

			// Delete the old selection.
			fw.getDocumentDOM().deleteSelection(false);

			// Do the stuff
			BezierArrow (leftX,leftY,rightX,rightY,myWidth,myHeight);

			// Remember the new selection.
			newSel[i] = fw.selection[0];

			// Apply the new attributes to the new rectangle.
			newSel[i].pathAttributes = pathAttrs;

			// Apply the effects to the new rectangle.
			newSel[i].effectList = effects;

			// Apply the opacity to the new rectangle.
			newSel[i].opacity = opacity;

		} // if elemType
	} // for  i
}
// no selection made - Draw an arrow with given width in the center
else {
	// Get the width from the user
	var myWidth = prompt("Give the width of the arrow:\nRange: Anything smaller than the document","250");

	// Make sure is a valid input - Don't check for null since myWidth has initial value from prompt()  if ( myWidth != null ) {   myWidth = parseInt(myWidth);   var myHeight = myWidth/myHeightRef;    //Make sure it is a number   if ( ! isNaN(myWidth) ) {     // Get the document size    var docWidth = fw.getDocumentDOM().width;    var docHeight = fw.getDocumentDOM().height;     // Make sure the Arrow will fit in the document    if ( myWidth ><= docWidth && myHeight <= docHeight ) {

 

                                // Calculate X,Y of the document center

                                var centDocX = docWidth / 2;

                                var centDocY = docHeight / 2;

 

                                // Based on centDocX, centDocY and myWidth, calculate  X,Y for the top left

                                // and bottom right corners of the area we will work

                                var leftX = centDocX - (myWidth/2);

                                var leftY = centDocY - (myHeight/2);

                                var rightX = leftX + myWidth;

                                var rightY = leftY + myHeight;

 

                                // Do the stuff

                                BezierArrow (leftX,leftY,rightX,rightY,myWidth,myHeight);

                       }

                       else {

                                alert("Sorry, but the arrow will not fit in your document. Please try again with different width");

                       }

             } // ! isNaN(myWidth)

                  else {

                       alert("The given width doesn't appear to be valid. Please try again!");

                  }

         } // myWidth != ""

}

 

กก