introduce clone(), add(), _add() members to L.Bounds

like we have for L.Point.

Change-Id: Ic7d1bf7d41f8d3e2cec2dab05ba0742342840775
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98147
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
This commit is contained in:
Dennis Francis 2020-06-05 16:55:18 +05:30
parent 844a9431c8
commit abe2a81e1f

View file

@ -30,6 +30,10 @@ L.Bounds.prototype = {
return this;
},
clone: function () { // -> Bounds
return new L.Bounds(this.min, this.max);
},
getCenter: function (round) { // (Boolean) -> Point
return new L.Point(
(this.min.x + this.max.x) / 2,
@ -91,6 +95,18 @@ L.Bounds.prototype = {
return xIntersects && yIntersects;
},
// non-destructive, returns a new Bounds
add: function (point) { // (Point) -> Bounds
return this.clone()._add(point);
},
// destructive, used directly for performance in situations where it's safe to modify existing Bounds
_add: function (point) { // (Point) -> Bounds
this.min._add(point);
this.max._add(point);
return this;
},
toString: function () {
return '[' +
this.min.toString() + ', ' +