Fixed grow method in container and shape class

This commit is contained in:
bluesaxman 2022-02-10 15:12:18 -07:00
parent 2cc3f4d0cf
commit 1469e59e97

View File

@ -77,8 +77,11 @@ class shape {
ctx.imageSmoothingEnabled = local.imageSmoothingEnabled; ctx.imageSmoothingEnabled = local.imageSmoothingEnabled;
} }
grow (amp) { grow (factor=1) {
this.dimentions = this.dimentions.amp(amp); factor = !isNaN(factor) ? factor : 1;
var half = this.dimentions.mag(factor/2);
this.dimentions = this.dimentions.mag(factor);
this.coordinates = this.coordinates.mag(factor);
} }
} }
@ -134,9 +137,12 @@ class container {
ctx.translate(-refPos.d[0],-refPos.d[1]); ctx.translate(-refPos.d[0],-refPos.d[1]);
} }
grow(amp) { grow(amp,includeBase) {
amp = !isNaN(amp) ? amp : 1; amp = !isNaN(amp) ? amp : 1;
this.position.mag(amp); if (includeBase) {
this.size = this.size.mag(amp);
this.coordinates = this.coordinates.mag(amp);
}
if (this.shapes.length) { if (this.shapes.length) {
this.shapes.forEach(shape => shape.grow(amp)); this.shapes.forEach(shape => shape.grow(amp));
} }