|
|
@ -60,19 +60,20 @@ class Box extends NodeBase { |
|
|
|
this.left = x - this.width * 0.5; |
|
|
|
this.top = y - this.height * 0.5; |
|
|
|
|
|
|
|
this.boundingBox.left = this.left; |
|
|
|
this.boundingBox.top = this.top; |
|
|
|
this.boundingBox.bottom = this.top + this.height; |
|
|
|
this.boundingBox.right = this.left + this.width; |
|
|
|
let borderRadius = this.options.shapeProperties.borderRadius; // only effective for box
|
|
|
|
this.boundingBox.left = this.left - borderRadius; |
|
|
|
this.boundingBox.top = this.top - borderRadius; |
|
|
|
this.boundingBox.bottom = this.top + this.height + borderRadius; |
|
|
|
this.boundingBox.right = this.left + this.width + borderRadius; |
|
|
|
} |
|
|
|
|
|
|
|
distanceToBorder(ctx, angle) { |
|
|
|
this.resize(ctx); |
|
|
|
let a = this.width / 2; |
|
|
|
let b = this.height / 2; |
|
|
|
let w = (Math.sin(angle) * a); |
|
|
|
let h = (Math.cos(angle) * b); |
|
|
|
return a * b / Math.sqrt(w * w + h * h); |
|
|
|
let borderWidth = this.options.borderWidth; |
|
|
|
|
|
|
|
return Math.min( |
|
|
|
Math.abs((this.width) / 2 / Math.cos(angle)), |
|
|
|
Math.abs((this.height) / 2 / Math.sin(angle))) + borderWidth; |
|
|
|
} |
|
|
|
} |
|
|
|
|