Strict Standards: Only variables should be passed by reference in /home/abeall/public_html/fireworks/download.php on line 28

Warning: Cannot modify header information - headers already sent by (output started at /home/abeall/public_html/fireworks/download.php:28) in /home/abeall/public_html/fireworks/download.php on line 44
// Fireworks JavaScript Command // Distributes source elements over the points of a target path // Install by copying this file to Fireworks/Configuration/Commands/Scatter.jsf // Run in Fireworks via the Commands menu // Aaron Beall 2007 - http://abeall.com // Version 1.4 /* BUGS - [FIXED-v1.1] first distributed object does not orient to path properly - [FIXED-v1.1] distribution objects don't orient intuitively, should use top on distribution object as direction - [FIXED-v1.1] path should be top most selected object to be more consistent with other commands - [DONE-v1.2] apply to selected points only - [CHANGED-v1.3] copyObject/pasteObject to copyNode/pasteNode - [CHANGED-v1.4] for..in loops changed to strict loops */ var dom = fw.getDocumentDOM(); // document object var sel = [].concat(fw.selection); // saved selection function DistributeToPoints(){ // validate selection if(sel.length<2) return alert("This command requires at least two selected objects. The top object must be a path, the bottom object(s) can be anything. The bottom objects will be duplicated and distributed to the top path's points."); if(sel[0] != '[object Path]') return alert("This command requires a path as the top most selected object. It will duplicate and distribute the objects selected below on the path's points."); // user input var orient = fw.yesNoDialog('Orient to path?'); // distribute elements along bottom path's points var path = sel[0], elemIndex = 0, elem, node, prevNode; var newElems = [], hasFillHandles = []; var contours = []; if(fw.activeTool == "Subselection"){ for(var c = 0; c < path.contours.length; c++){ contours[c] = {nodes:[]}; for(var n = 0; n < path.contours[c].nodes.length; n++){ var node = path.contours[c].nodes[n]; contours[c].nodes.push({x:node.x, y:node.y, predX:node.predX, predY:node.predY, succX:node.succX, succY:node.succY, isSelectedPoint:node.isSelectedPoint}); } } }else contours = path.contours; for(var c = 0; c < contours.length; c++){ if(orient){ prevNode = {x:contours[c].nodes[0].x, y:contours[c].nodes[0].y}; prevNode.x -= contours[c].nodes[1].x - prevNode.x; prevNode.y -= contours[c].nodes[1].y - prevNode.y; } var nlen = contours[c].nodes.length; for(var n = 0; n < nlen; n++){ if(++elemIndex > sel.length - 1) elemIndex = 1; node = contours[c].nodes[n]; if(fw.activeTool != "Subselection" || node.isSelectedPoint){ fw.selection = [sel[elemIndex]]; dom.cloneSelection(); elem = fw.selection[0]; //elem.left = Math.round(node.x - elem.width/2); //elem.top = Math.round(node.y - elem.height/2); if(hasFillHandles[elemIndex] == undefined) hasFillHandles[elemIndex] = elem.pathAttributes && elem.pathAttributes.fill && elem.pathAttributes.fill.gradient; if(hasFillHandles[elemIndex]) dom.clipCopy(); dom.moveSelectionTo({x:Math.round(node.x - elem.width * .5), y:Math.round(node.y - elem.height * .5)},false,false); if(hasFillHandles[elemIndex]) dom.clipPasteAttributes(); if(orient) dom.rotateSelection(getAngle(prevNode, node), "autoTrimImages transformAttributes"); newElems.push(fw.selection[0]); } if(orient) prevNode = node; } } // set selection to all the newly distributed elements fw.selection = newElems; return true; } DistributeToPoints(); // get the angle in degrees between two points function getAngle(p1, p2){ return -Math.atan2((p1.x - p2.x), (p1.y - p2.y)) * (180 / Math.PI); }