|
|
@ -138,14 +138,23 @@ class Branch { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
draw(pos) { |
|
|
|
draw(pos) { |
|
|
|
var branch = new Path(); |
|
|
|
if(typeof this._crown !== "undefined") { |
|
|
|
|
|
|
|
this._crown.removeSegments(); |
|
|
|
|
|
|
|
delete this._crown; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(typeof this._branch !== "undefined") { |
|
|
|
|
|
|
|
this._branch.removeSegments(); |
|
|
|
|
|
|
|
delete this._branch; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._branch = new Path(); |
|
|
|
var bvec = new Point(Math.cos(this.angle) * this.length, |
|
|
|
var bvec = new Point(Math.cos(this.angle) * this.length, |
|
|
|
-1 * Math.sin(this.angle) * this.length); |
|
|
|
-1 * Math.sin(this.angle) * this.length); |
|
|
|
var end = pos.add(bvec); |
|
|
|
var end = pos.add(bvec); |
|
|
|
branch.strokeColor = 'black'; |
|
|
|
this._branch.strokeColor = 'black'; |
|
|
|
branch.strokeWidth = 2; |
|
|
|
this._branch.strokeWidth = 2; |
|
|
|
branch.add(pos); |
|
|
|
this._branch.add(pos); |
|
|
|
branch.add(end); |
|
|
|
this._branch.add(end); |
|
|
|
|
|
|
|
|
|
|
|
if(typeof this.crown !== "undefined") { |
|
|
|
if(typeof this.crown !== "undefined") { |
|
|
|
console.log("CROWN"); |
|
|
|
console.log("CROWN"); |
|
|
@ -155,19 +164,19 @@ class Branch { |
|
|
|
var bswidth = this.crown.length * this.crown.width; |
|
|
|
var bswidth = this.crown.length * this.crown.width; |
|
|
|
var bsvec = new Point(Math.sin(this.angle) * bswidth / 2, |
|
|
|
var bsvec = new Point(Math.sin(this.angle) * bswidth / 2, |
|
|
|
Math.cos(this.angle) * bswidth / 2); |
|
|
|
Math.cos(this.angle) * bswidth / 2); |
|
|
|
var crown = new Path(); |
|
|
|
this._crown = new Path(); |
|
|
|
crown.strokeColor = 'black'; |
|
|
|
this._crown.strokeColor = 'black'; |
|
|
|
crown.fillColor = 'white'; |
|
|
|
this._crown.fillColor = 'white'; |
|
|
|
crown.strokeWidth = 2; |
|
|
|
this._crown.strokeWidth = 2; |
|
|
|
crown.closed = true; |
|
|
|
this._crown.closed = true; |
|
|
|
//crown.selected = true;
|
|
|
|
//this._crown.selected = true;
|
|
|
|
crown.add(end); |
|
|
|
this._crown.add(end); |
|
|
|
crown.add(end.add(cvec.multiply(this.crown.bisect)) |
|
|
|
this._crown.add(end.add(cvec.multiply(this.crown.bisect)) |
|
|
|
.add(bsvec)); |
|
|
|
.add(bsvec)); |
|
|
|
crown.add(end.add(cvec)); |
|
|
|
this._crown.add(end.add(cvec)); |
|
|
|
crown.add(end.add(cvec.multiply(this.crown.bisect)) |
|
|
|
this._crown.add(end.add(cvec.multiply(this.crown.bisect)) |
|
|
|
.subtract(bsvec)); |
|
|
|
.subtract(bsvec)); |
|
|
|
console.log(crown); |
|
|
|
console.log(this._crown); |
|
|
|
|
|
|
|
|
|
|
|
} else if(this.crown.shape = "triangle") { |
|
|
|
} else if(this.crown.shape = "triangle") { |
|
|
|
console.log("TRIANGLE"); |
|
|
|
console.log("TRIANGLE"); |
|
|
@ -175,16 +184,16 @@ class Branch { |
|
|
|
var bswidth = this.crown.length * this.crown.width; |
|
|
|
var bswidth = this.crown.length * this.crown.width; |
|
|
|
var bsvec = new Point(Math.sin(this.angle) * bswidth / 2, |
|
|
|
var bsvec = new Point(Math.sin(this.angle) * bswidth / 2, |
|
|
|
Math.cos(this.angle) * bswidth / 2); |
|
|
|
Math.cos(this.angle) * bswidth / 2); |
|
|
|
var crown = new Path(); |
|
|
|
this._crown = new Path(); |
|
|
|
crown.strokeColor = 'black'; |
|
|
|
this._crown.strokeColor = 'black'; |
|
|
|
crown.fillColor = 'white'; |
|
|
|
this._crown.fillColor = 'white'; |
|
|
|
crown.strokeWidth = 2; |
|
|
|
this._crown.strokeWidth = 2; |
|
|
|
crown.closed = true; |
|
|
|
this._crown.closed = true; |
|
|
|
//crown.selected = true;
|
|
|
|
//this._crown.selected = true;
|
|
|
|
crown.add(end.add(bsvec)); |
|
|
|
this._crown.add(end.add(bsvec)); |
|
|
|
crown.add(end.add(cvec)); |
|
|
|
this._crown.add(end.add(cvec)); |
|
|
|
crown.add(end.subtract(bsvec)); |
|
|
|
this._crown.add(end.subtract(bsvec)); |
|
|
|
console.log(crown); |
|
|
|
console.log(this._crown); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|