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 // Copy to Fireworks/Configuration/Commands/ // Aaron Beall - http://abeall.com /* TODO: - [DONE] recursive into groups and masks - recursive into symbol contents - [DONE] profile fills and strokes - [DONE] profile number of pixels - [DONE] profile masks */ var dom = fw.getDocumentDOM(); var sel = fw.selection; function ProfileSelection(){ if(!fw.selection.length) return alert('You have nothing selected.'); var profile = {contours:0,nodes:0,curves:0,isClosed:0,textRuns:0,characters:0,groups:0,masks:0,maskees:0,fills:0,strokes:0,solidFills:0,antialiasFills:0,featherFills:0,hardFills:0,gradientFills:0,patternFills:0,texturedFills:0,pixels:0}; profile.strokeTypes = {}; profile.elemTypes = {}; profile.colors = {}; var elem, numTypes = 0, numColors = 0, numElems = 0, numStroketypes = 0, type, stroketype, recursive = null; doProfile(sel); function doProfile(elems, isMask){ for(var e in elems){ if(isMask) profile.masks++; elem = elems[e]; numElems++; type = String(elem).split('[object ')[1]; type = type.substring(0,type.length-1); if(!profile.elemTypes[type]){ profile.elemTypes[type] = 0; numTypes++; } profile.elemTypes[type] += 1; switch(type){ case 'Path': for(var c in elem.contours){ profile.contours++; if(elem.contours[c].isClosed) profile.isClosed++; profile.nodes += elem.contours[c].nodes.length for(var n in elem.contours[c].nodes){ var node = elem.contours[c].nodes[n]; if(node.x != node.predX || node.x != node.succX || node.y != node.predY || node.y != node.succY) profile.curves++; } } break; case 'Text': profile.textRuns += elem.textRuns.textRuns.length; if(!profile.colors[elem.textRuns.initialAttrs.fillColor]){ profile.colors[elem.textRuns.initialAttrs.fillColor] = true; numColors++; } for(var t in elem.textRuns.textRuns){ profile.characters += elem.textRuns.textRuns[t].characters.length; if(elem.textRuns.textRuns[t].changedAttrs.fillColor){ if(!profile.colors[elem.textRuns.textRuns[t].changedAttrs.fillColor]){ profile.colors[elem.textRuns.textRuns[t].changedAttrs.fillColor] = true; numColors++; } } } break; case 'Group': profile.groups++; if(recursive==null) recursive = fw.yesNoDialog('Do you wish to profile group contents as well?'); if(recursive) doProfile(elem.elements,isMask); break; case 'Image': profile.pixels += elem.width*elem.height; break; } if(elem.pathAttributes){ if(elem.pathAttributes.fill){ profile.fills++; if(elem.pathAttributes.fill.feather){ profile.featherFills++; }else if(elem.pathAttributes.fill.edgeType == 'hard'){ profile.hardFills++; }else{ profile.antialiasFills++; } if(elem.pathAttributes.fill.gradient){ profile.gradientFills++; for(var n in elem.pathAttributes.fill.gradient.nodes){ if(!profile.colors[elem.pathAttributes.fill.gradient.nodes[n].color]){ profile.colors[elem.pathAttributes.fill.gradient.nodes[n].color] = true; numColors++; } } }else{ if(!profile.colors[elem.pathAttributes.fillColor]){ profile.colors[elem.pathAttributes.fillColor] = true; numColors++; } if(elem.pathAttributes.fill.pattern){ profile.patternFills++; }else{ profile.solidFills++; } } if(elem.pathAttributes.fill.textureBlend) profile.texturedFills++; } if(elem.pathAttributes.brush){ profile.strokes++; if(!profile.colors[elem.pathAttributes.brushColor]){ profile.colors[elem.pathAttributes.brushColor] = true; numColors++; } stroketype = elem.pathAttributes.brush.name; stroketype = stroketype.substr(3); if(!profile.strokeTypes[stroketype]){ numStroketypes++; profile.strokeTypes[stroketype] = 0; } profile.strokeTypes[stroketype]++; } } if(elem.mask){ profile.maskees++; doProfile([elem.mask.element],true); } } } // generate profile string var str = ''; if(numTypes==1){ str += 'You have '+numElems+' '+type+(numElems>1?'s':'')+' selected.'; }else{ str += 'You have '+numElems+' elements selected: '; for(var i in profile.elemTypes) str += profile.elemTypes[i]+' '+i+(profile.elemTypes[i]>1?'s':'')+', '; str = str.substring(0,str.length-2)+'.'; } if(profile.maskees){ str = str.substring(0,str.length-1); str += ' -- '+profile.maskees+' element'+(profile.maskees>1?'s are ':' is ')+'masked, '+profile.masks+' element'+(profile.masks>1?'s are ':' is a ')+'mask'+(profile.masks>1?'s':'')+'.'; } if(profile.elemTypes['Path']){ str += '\nThere '+(profile.contours>1?'are ':'is '); str += profile.contours+' contour'+(profile.contours>1?'s ':'')+'('+profile.isClosed+' closed)'; str += ' and '+profile.nodes+' node'+(profile.nodes>1?'s ':'')+'('+profile.curves+' curved).'; } if(profile.elemTypes['Text']){ str += '\nThere '+(profile.textRuns>1?'are ':'is '); str += profile.textRuns+' text run'+(profile.textRuns>1?'s':''); str += ' with '+profile.characters+' character'+(profile.characters>1?'s':'')+'.'; } if(profile.fills){ str += '\nThere '+(profile.fills>1?'are':'is')+' '+profile.fills+' fill'+(profile.fills>1?'s':'')+': '; if(profile.hardFills) str += profile.hardFills+' solid, '; if(profile.antialiasFills) str += profile.antialiasFills+' anti-aliased, '; if(profile.featherFills) str += profile.featherFills+' feathered, '; if(profile.solidFills) str += profile.solidFills+' solid, '; if(profile.gradientFills) str += profile.gradientFills+' gradient'+(profile.gradientFills>1?'s':'')+', '; if(profile.patternFills) str += profile.patternFills+' pattern'+(profile.patternFills>1?'s':'')+', '; if(profile.texturedFills) str += profile.texturedFills+' textured, '; str = str.substring(0,str.length-2)+'.'; } if(profile.strokes){ str += '\nThere '+(profile.strokes>1?'are':'is')+' '+profile.strokes+' stroke'+(profile.strokes>1?'s':'')+': '; if(numStroketypes){ for(var i in profile.strokeTypes) str += profile.strokeTypes[i]+' '+i+', '; str = str.substring(0,str.length-2)+'.'; } } if(profile.pixels){ str += '\nThere '+(profile.pixels>1?'are ':'is ')+profile.pixels+' pixel'+(profile.pixels>1?'s':'')+'.'; } if(numColors){ str += '\nThere '+(numColors==1?'is':'are')+' '+numColors+' unique color'+(numColors==1?'':'s')+(profile.pixels?'(not including pixels)':'')+'.'; } fw.saveJsCommand('/*\n'+str+'\n*/\n\nalert("'+str.split('\n').join('\\n')+'");','Last Selection Profile'); return alert(str); } ProfileSelection();