// Project Fireworks 2000
// Kleanthis E. -- kleanthis@projectfireworks.com
// http://projectfireworks.com
// revised for Fireworks 4
if ( fw.selection != null && fw.selection.length > 0 ) {
// get the original Selection
var origSel = fw.selection;
// count the errors
var numOfErrorsBecauseOfSize = 0;
// get the reoundness from the user
userInput = prompt("Please enter the new roundness of the Bitmap(s) in pixels.");
//make sure its a number
if ( isNaN(userInput) || userInput == null || userInput == "" ) {
alert("Your input was invalid. Please try again...");
}
else {
for ( i in origSel ) {
// make sure we have a bitmap
if ( origSel[i].toString() == "[object Image]" ) {
//get each object
var newSel = new Array(1);
newSel[0] = origSel[i];
// meke each object the current FW selection
fw.selection = newSel[0];
// get the bounds
var mySelection = new PF_selectionBounds();
// see if it's smaller than the small side of the bitmap
if ( mySelection.smallSide/2 > userInput ) {
// Set the Fill
fw.getDocumentDOM().setFillNColorNTexture({
category:"fc_Solid",
ditherColors:[ "#000000", "#000000" ],
edgeType:"antialiased",
feather:0},"#000000", "Grain");
// Draw the rectangle
fw.getDocumentDOM().addNewRectangle(
{left: mySelection.left,
top: mySelection.top,
right:mySelection.right,
bottom: mySelection.bottom},
userInput/(mySelection.smallSide/2) );
fw.getDocumentDOM().clipCut();
fw.selection = origSel;
fw.getDocumentDOM().clipPasteAsMask("ask user", "vector", "ask user");
} // if valid size/roundness
else{
numOfErrorsBecauseOfSize++;
}
} // if its bitmap
}//for
}
if ( numOfErrorsBecauseOfSize ) {
alert("The command was not applied to " + numOfErrorsBecauseOfSize + " bitmap(s) because \nthe given roundness was to high.");
}
}
else { // no selection made
alert("This command requires one object to be selected.\nPlease alter your selection and try again.");
}
function PF_selectionBounds(){// v.1.0
var mySelectionBounds = fw.getDocumentDOM().getSelectionBounds();
this.left = mySelectionBounds.left;
this.top = mySelectionBounds.top;
this.right = mySelectionBounds.right;
this.bottom = mySelectionBounds.bottom;
this.width = this.right - this.left;
this.height = this.bottom - this.top;
this.smallSide = (this.width < this.height) ? this.width : this.height;
this.bigSide = (this.width > this.height) ? this.width : this.height;
} // PF_getSelectionBounds
กก |