for the life of me i cant figure out why this wont work
you can pretty much ignore this whole part between the *'s, im just including it incase somehow my error is in there,
anyway, the problem is in the while loop at the bottom, it keeps drawing the lines in the same place (it draws 11), even though im clearly telling it to move the end point over.........
thanks in advance!
//********************
function onInit() {
size = .5;
startX = 0;
startY = 0;
boxSize = 20;
hop = 2;
}
function onOptions() {
size = Dialog.prompt("Random Scribbler:", [ { description: "Radius", value: size, width: 50} ])[0];
}
function onMouseDown(event) {
path = new Path();
path.moveTo(event.point);
}
function onMouseUp(event) {
//point = event.point;
startX = event.point.getX();
startY = event.point.getY();
point = new Point();
point2 = new Point();
p1ModX=0;
p1ModY=0;
p2ModX=0;
p2ModY=0;
point = new Point(startX,startY);
point2 = event.point;
point = point.add( (boxSize/2) ,0);
//p1
p1Side = Math.round(1 + Math.random() * (2 - 1));
p1Start = Math.round(0 + Math.random() * (boxSize - 0));
if(p1Side == 1) //top
{
point.setX(startX+p1Start);
point.setY(startY);
}
if(p1Side == 2) //left
{
point.setX(startX);
point.setY(startY-p1Start);
}
//p2
p2Side = Math.round(1 + Math.random() * (2 - 1));
p2Start = Math.round(0 + Math.random() * (boxSize - 0));
if(p2Side == 1) //right
{
point2.setX(startX+boxSize);
point2.setY(startY-p2Start);
}
if(p2Side == 2) //bottom
{
point2.setX(startX+p2Start);
point2.setY(startY-boxSize);
}
point3 = new Point();
point4 = new Point();
point3 = point;
point4 = point2;
test=10;
//********************
while( (point.getY() >= (startY-boxSize+hop)) && (point2.getX() >= (startX+hop)) && test >0)
{
//draw lines
point2.subtract(hop,0);
test--;
path = new Path();
path.moveTo(point);
path.lineTo(point2);
}
}