paper.install(window); window.onload = function() { var canvas = document.getElementById('grower'); canvas.width = 300; canvas.height = 300; paper.setup(canvas); Leaf.veinArea = new Path(); Leaf.auxinArea = new Path(); Leaf.size = 100; //200; Leaf.auxinR = 9; Leaf.veinR = Leaf.auxinR; Leaf.auxinNr = 15; Leaf.veinGrowRate = 1.5; Leaf.leafGrowRate = 3; //1.04; Leaf.maxGrowIters = 10; //Leaf.maxSize = 1338*0.75; //legs //Leaf.maxSize = 1511*0.75; //seat Leaf.maxSize = 290; Leaf.branches = []; Leaf.auxin = []; Leaf.color = new Color(0.8, 0.8, 0.8); Leaf.midlayerItems = []; Leaf.frontlayerItems = []; Leaf.finishedShape = new Path(); Leaf.finished = false; Leaf.final = false; //Leaf.mouse = new Path.Circle(new Point(0,0),10); Leaf.uniform = true; var leaf = new Leaf(new Point(view.bounds.width/2,view.bounds.height/2)); Leaf.trycount = 10; /*view.onClick = function(event){ var svg = project.exportSVG({ asString: true }); var svgBlob = new Blob([svg], {type:"image/svg+xml;charset=utf-8"}); var svgUrl = URL.createObjectURL(svgBlob); var downloadLink = document.createElement("a"); downloadLink.href = svgUrl; downloadLink.download = "growth.svg"; document.body.appendChild(downloadLink); downloadLink.click(); document.body.removeChild(downloadLink); }*/ view.onFrame = function(event) { // On each frame, rotate the path by 3 degrees: if(leaf.shape.bounds.heightLeaf.veinR && !this.auxinTooClose(point)){ //if(this.isEmptyAuxinNeighbourhood(point) && this.isEmptyVeinNeighbourhood(point)){ this.auxin.push(new Auxin(point)); f = true; //tmp.fillColor = 'green'; //Leaf.auxinArea.strokeColor = 'red'; //} } } return f; } auxinTooClose(point){ for(var i = 0; iLeaf.veinR){ newauxin.push(this.auxin[i]); }else{ this.auxin[i].remove(); } } this.auxin = newauxin; } attractVeins(){ for(var i = 0; i0){ var newPath = this.path.splitAt(this.path.getLocationOf(this.childBranches[0].path.firstSegment.point)); //newPath.strokeColor = Color.random(); var newBranch = new VeinBranch(); newBranch.path = newPath; console.log(newBranch.childBranches); for(var i = 1; i (this.path.getOffsetOf(a.path.firstSegment.point) > this.path.getOffsetOf(b.path.firstSegment.point)) ? 1 : -1) //console.log(this.childBranches); for(var i = 0; i=0; i--){ if(this.childBranches[i].path.length0){ var direction = new Point(0,0); var oldDists = []; for(var i = 0; i