var footstring2 = `
`;
var footstring = `
`;
var seatstring = `
`;
paper.install(window);
window.onload = function() {
// Setup directly from canvas id:
paper.setup('myCanvas');
Leaf.veinArea = new Path();
Leaf.auxinArea = new Path();
Leaf.size = 100; //200;
Leaf.auxinR = 13;
Leaf.veinR = Leaf.auxinR;
Leaf.auxinNr = 30;
Leaf.veinGrowRate = 2;
Leaf.leafGrowRate = 2; //1.04;
Leaf.maxGrowIters = 100;
//Leaf.maxSize = 1338*0.75; //legs
//Leaf.maxSize = 1511*0.75; //seat
Leaf.maxSize = 500;
Leaf.branches = [];
Leaf.auxin = [];
Leaf.color = Color.random();
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-100));
Leaf.trycount = 10;
/*view.onMouseDown = function(event){
//leaf.iteration();
//console.log(leaf.veins);
}
view.onMouseMove = function(event){
//Leaf.mouse.position = event.point;
//var b = leaf.veins.getClosestBranch(event.point);
//Leaf.mouse.fillColor = b.path.strokeColor;
//console.log(leaf.veins);
}*/
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