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 Arcs (bends/distorts) the bottom of vector selection Install by copying to Fireworks/Configuration/Commands/ Run in Fireworks via the Commands menu Aaron Beall 2009 - http://abeall.com Version 1.1 TODO: - Add handles to straight node edges - Keep curve point handles tangent */ var dom = fw.getDocumentDOM(); var sel = [].concat(fw.selection); // params var STRENGTH; // int; maximum y translation of points var OFFSET; // 0-1; x midpoint of arc // arc-bottom distortion function arcBottom(){ // require active document if (!dom) return false; // convert text to paths // TODO: find text inside groups for(var i in sel){ if(sel[i] == '[object Text]'){ if(confirm('Text will be converted to paths. Continue?')) dom.convertToPaths(); else return false; } sel = [].concat(fw.selection); } // find all selected paths, including in groups var paths = []; function pathsIn(elems){ for(var e in elems){ if(elems[e] == '[object Path]') paths.push(elems[e]); if(elems[e] == '[object Group]') pathsIn(elems[e].elements) } } pathsIn(sel); if(!paths.length) return alert('This command requires at least one selected path or text to be deformed.'); // acquire user input var input; do{ input = prompt("Strength, Offset(0-1):",input||fw.ArcBottom_input||'50,0.5'); if(input==null) return false; }while(!validate()); // user input result fw.ArcBottom_input = input; STRENGTH = Number(input[0]); OFFSET = Number(input[1]); // validate user input function validate(){ input = String(input).split(','); if(input.length != 2 && input.length != 1) return alert('Invalid input!'); if(input.length == 1) input[1] = '.5'; if(isNaN(Number(input[0])) || isNaN(Number(input[1]))) return alert('Invalid input! Enter numeric values only.'); if(Number(input[1]) < 0 || Number(input[1]) > 1) return alert('Invalid input! Enter a value range from 0 to 1 for Offset.'); return true; } // init fw.selection = paths; var bounds = dom.getSelectionBounds(); var width = bounds.right-bounds.left, height = bounds.bottom-bounds.top; // distort var contours, nodes, node, pt, xWeight, yWeight, yDelta; var points = [['x','y'],['predX','predY'],['succX','succY']]; for(var p in paths){ contours = paths[p].contours; for(var c in contours){ nodes = contours[c].nodes; for(var n in nodes){ node = nodes[n]; for(var i in points){ pt = points[i]; xWeight = (node[pt[0]]-bounds.left)/width - OFFSET; yWeight = (node[pt[1]]-bounds.top)/height; yDelta = interpolateQuad(xWeight,STRENGTH)*yWeight; node[pt[1]] += yDelta; } } } } // restore selection fw.selection = sel; } //try{ arcBottom(); //}catch(e){alert(['error',e.lineNumber])} // quadratic in/out interpolation function interpolateQuad(t, c){ if ((t/=1/2) < 1) return c/2*t*t; return -c/2 * ((--t)*(t-2) - 1); }