MCPcopy Create free account
hub / github.com/melonjs/melonJS / union

Method union

packages/melonjs/src/geometries/rectangle.ts:192–204  ·  view source on GitHub ↗

* merge this rectangle with another one * @param rect - other rectangle to union with * @returns the union(ed) rectangle

(rect: Rect)

Source from the content-addressed store, hash-verified

190 * @returns the union(ed) rectangle
191 */
192 union(rect: Rect) {
193 const x1 = Math.min(this.left, rect.left);
194 const y1 = Math.min(this.top, rect.top);
195
196 this.resize(
197 Math.max(this.right, rect.right) - x1,
198 Math.max(this.bottom, rect.bottom) - y1,
199 );
200
201 this.pos.set(x1, y1);
202
203 return this;
204 }
205
206 /**
207 * check if this rectangle is intersecting with the specified one

Callers 1

rectangle.spec.tsFile · 0.80

Calls 2

resizeMethod · 0.95
setMethod · 0.45

Tested by

no test coverage detected