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

Function fixOverlappingCorners

packages/melonjs/src/polyfill/roundrect.ts:326–345  ·  view source on GitHub ↗

@ignore

(corners: any)

Source from the content-addressed store, hash-verified

324
325 /** @ignore */
326 function fixOverlappingCorners(corners: any) {
327 const [upperLeft, upperRight, lowerRight, lowerLeft] = corners;
328 const factors = [
329 // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
330 Math.abs(w) / (upperLeft.x + upperRight.x),
331 // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
332 Math.abs(h) / (upperRight.y + lowerRight.y),
333 // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
334 Math.abs(w) / (lowerRight.x + lowerLeft.x),
335 // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
336 Math.abs(h) / (upperLeft.y + lowerLeft.y),
337 ];
338 const minFactor = Math.min(...factors);
339 if (minFactor <= 1) {
340 corners.forEach((radii: any) => {
341 radii.x *= minFactor;
342 radii.y *= minFactor;
343 });
344 }
345 }
346}
347
348if (globalThis.CanvasRenderingContext2D) {

Callers 1

roundRectFunction · 0.85

Calls 2

absMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected