/* ++++++++++++++++++++++++++++++++++++++++++++
       _____           __
      / __(_)_______  / /__
     / /_/ /_  /_  / / / _ \
    / __/ / / /_/ /_/ /  __/
   /_/ /_/ /___/___/_/\___/
                            __
      ____ ___  ____ ______/ /____  _____
     / __ `__ \/ __ `/ ___/ __/ _ \/ ___/
    / / / / / / /_/ (__  ) /_/  __/ /
   /_/ /_/ /_/\__,_/____/\__/\___/_/

      _____ ____  ____  ____
     |__  // __ \/ __ \/ __ \ TM
      /_ </ / / / / / / / / /
    ___/ / /_/ / /_/ / /_/ /
   /____/\____/\____/\____/
   
   by pedro and rob :)
   
   
   fizzlemaster3000.js is a drawing tool
   which creates grass-like vectors (fizzles)
   shooting out of the drawn path.
   
   you can set values like the direction
   those fizzles should point at, the
   growth/lenght of the generated vectors,
   their value of disturbance and the
   amount of fizzles created per mousedrag.
   
+++++++++++++++++++++++++++++++++++++++++++++ */ 


function onInit() {
degree = 52;
length = 80;
difference = 30;
amount = 4;
baseline = 1;
}

function onOptions() {
	var values = Dialog.prompt("fizzlemaster3000", [
	{ value: degree, description: "1 - direction:  (in degree)", width: 50 },
	{ value: length, description: "2 - growth:  (0 = short / 100 = long)", width: 50 },
	{ value: difference, description: "3 - disturbance:  (0 = boring / 50 = wild)", width: 50 },
	{ value: amount, description: "4 - bunches:  (1 = one bunch / 50 = fifty bunches)", width: 50 }
	]);
	

  if (values != null) {
    degree = values[0];
    length = values[1];
    difference = values[2];
    amount = values[3];
    baseline = values[4];
    }
}

function onMouseDown(event) {
    paths = new Array(amount);
    for (i = 0; i < amount; i++) {
        paths[i] = new Path();
    }
    basepath = new Path();
}

function onMouseUp(event) {
//oh no it's empty :(
}

function onMouseDrag(event) {
    for (i = 0; i < amount; i++) {
        paths[i].segments.add(event.point.add(0,0));
    
        var rand_degree = degree + ( ((Math.random() - 0.5) * 2.0) * difference );
        var rand_length = length * Math.random();
        var rad = -(rand_degree-90) * Math.PI / 180;
        var x = Math.cos(rad) * rand_length;
        var y = Math.sin(rad) * rand_length;

        paths[i].segments.add(event.point.add(x,y));
    }
   if (baseline == 1) basepath.segments.add(event.point.add(0,0));
}
