// draws random lines between points at a set distance along a path to make a spider web// I used the wonderfully documented wallblazer2.0 script from // the mighty graf salamander as a starting point.// I was trying to recreate the nodebox script "spider".// this version is much simpler in the way it passes all selected objects to the startWeb functionvar pointDist = 10; // distance between pointsvar useCurve = false; //use a curve instead of a straight linevar randomize = false; // randomize the distance between points on original pathvar killbase = false; // if used on objects, keep the object/base (false --> kill the base)var strokeRand = false; //used to check if the stroke should be randomizedvar minStroke = .5; // minstroke and maxstroke define the range for the randomized strokevar maxStroke = 3;var clr = new CMYKColor(0,0,0,1); // set stroke color to black, if the selected objects already have a strok color, that will be used. values = Dialog.prompt("set Spider Web values", [	{ value: pointDist, description: "point distance", width: 50 },	{ value: useCurve, description: "use curves", width: 50 },	//{ value: randomize, description: "randomize distance", width: 50 },	{ value: killbase, description: "remove original path", width: 50 },	{ value: strokeRand, description: "use random stroke widths", width: 50 },	{ value: minStroke, description: "minimum stroke width", width: 50 },	{ value: maxStroke, description: "maximum stroke width", width: 50 }]);if (values != null ) {	pointDist = values[0];	useCurve = values[1];	killbase = values[2];	strokeRand = values[3];	minStroke = values[4];	maxStroke = values[5];	//randomize = values[6];	var sel = document.getItems({ type: Path, selected: true }); 	for (var i = 0; i < sel.length; i++) {			art = sel[i];			startWeb(art);	}}function startWeb(webObj){	base = webObj.clone(); // create a clone of the webObj in case you would keep the base object	if (webObj.strokeColor != null) clr = base.strokeColor; //if webObj has a stroke colour, use it. doesn't work with spot colors.	if (randomize == true){		// var length = webObj.segments.length;		//for (var i = 0; i < length){			// I want to add code here to add new anchor points at random intervals around the path.			// not sure how to do it. Anyone's suggestions would be welcome :)					//}	} else{		webObj.curvesToPoints(pointDist, 10000); // creates anchorpoints on the webObj, the distance between the points is set in the options dialog	}	var group = new Group();  // a new empty group		var count = webObj.curves.length-1; // get the count of anchorpoints	//print (count);	for (var j = 0; j < count; j++)	{		var path = new Path(); // create a new path element		path.moveTo(webObj.curves[j].point1); // set the start point of the path (the anchotpoint on the webObj)		path.strokeColor = clr;		if (strokeRand == true){			path.strokeWidth = minStroke + Math.random() * (maxStroke - minStroke); // sets a random stroke		}		var rpoint = webObj.curves[Math.round(Math.random()*count)].point1; //choose a point randomly on the webObj path		if (useCurve == true){			var cpoint1 = webObj.curves[Math.round(Math.random()*count)].point1;			var cpoint2 = webObj.curves[Math.round(Math.random()*count)].point1;			path.curveTo(cpoint1, cpoint2, rpoint);		} else {			path.lineTo(rpoint);		}		group.appendChild(path); // add the path to a group			}	//print ("out of j loop");	webObj.remove();	if (killbase == true){		base.remove();	} else {		var maingroup = new Group();		maingroup.appendChild(base);		maingroup.appendChild(group);	}		//print ("done with startWeb");	return webObj;	}	
