// Project Fireworks (c) 2000 Kleanthis Economou
// Wave Line: If no selection is made, it draws a
// wave line for given length, wave length and wave height
// if selection is made, it uses the selection width and
// prompts for wave length and wave height
//---------------------------------------------------------
// ekleanthis@hotmail.com
// http://projectzero.webhostme.com
// --------------------------------------------------------
// Known issue: Instead of using the actuall bezier function
// I "simulated" it.
// Result: The biger the wave Height, the more off we are
// approx 4px every 100px
function waveLine( pt1_X, pt1_Y, lineLength, waveLength, waveHeight )
// by Kleanthis Economou
{
var paramNum = 10/3;
fw.getDocumentDOM().addNewSinglePointPath({x:pt1_X, y:pt1_Y+(paramNum*waveHeight)}, {x:pt1_X, y:pt1_Y}, {x:pt1_X, y:pt1_Y-(paramNum*waveHeight)}, true);
var numOfPoints = (lineLength/waveLength);
for ( i= 1; i
// Get the selection Size
var selectBounds = fw.getDocumentDOM().getSelectionBounds();
var selectLeft = selectBounds.left;
var selectTop = selectBounds.top;
var selectRight = selectBounds.right;
var selectBottom = selectBounds.bottom;
var waveDimPrompt = prompt("Enter the Dimentions of the Wave Line to draw.\nFormat: Wave Length, Wave Height", "50, 15");
if ( waveDimPrompt != "" ) {
waveDimPrompt = waveDimPrompt.replace(" ","");
var arrayWaveDim = waveDimPrompt.split(",");
var lineLength = selectRight - selectLeft;
var waveLength = arrayWaveDim[0];
var waveHeight = arrayWaveDim[1];
if (!isNaN(waveLength) && !isNaN(waveHeight)) {
//Calc the first point
var pt1_X = selectLeft;
var pt1_Y = selectTop + (selectBottom - selectTop)/2;
waveLine(pt1_X, pt1_Y, lineLength, waveLength, waveHeight);
}
else {
alert("Invalid Data. Please try again...");
}
}
else {
alert("The dimensions of the Wave Line can't be blank. Please try again...");
}
}
else {
// ask for Dimension
var waveDimPrompt = prompt("Enter the Dimentions of the Wave Line to draw.\nFormat: Line Length, Wave Length, Wave Height", "150, 50, 15");
if ( waveDimPrompt != "" ) {
waveDimPrompt = waveDimPrompt.replace(" ","");
var arrayWaveDim = waveDimPrompt.split(",");
var lineLength = arrayWaveDim[0];
var waveLength = arrayWaveDim[1];
var waveHeight = arrayWaveDim[2];
if ( !isNaN(lineLength) && !isNaN(waveLength) && !isNaN(waveHeight)) {
// Calc the coordinates of the first bezier point
var pt1_X = docX - (lineLength/2);
var pt1_Y = docY;
waveLine(pt1_X, pt1_Y, lineLength, waveLength, waveHeight);
}
else {
alert("Invalid Data. Please try again...");
}
}
else {
alert("The dimensions of the Wave Line can't be blank. Please try again...");
}
}
กก |