{"version":3,"file":"drawFilletRect.mjs","sources":["../src/drawFilletRect.ts"],"sourcesContent":["import type { Graphics } from '@pixi/graphics';\n\n/**\n * Draw Rectangle with fillet corners. This is much like rounded rectangle\n * however it support negative numbers as well for the corner radius.\n *\n * _Note: Only available with **@pixi/graphics-extras**._\n * @method PIXI.Graphics#drawFilletRect\n * @param this\n * @param {number} x - Upper left corner of rect\n * @param {number} y - Upper right corner of rect\n * @param {number} width - Width of rect\n * @param {number} height - Height of rect\n * @param {number} fillet - accept negative or positive values\n * @returns {PIXI.Graphics} Returns self.\n */\nexport function drawFilletRect(this: Graphics,\n    x: number,\n    y: number,\n    width: number,\n    height: number,\n    fillet: number): Graphics\n{\n    if (fillet === 0)\n    {\n        return this.drawRect(x, y, width, height);\n    }\n\n    const maxFillet = Math.min(width, height) / 2;\n    const inset = Math.min(maxFillet, Math.max(-maxFillet, fillet));\n    const right = x + width;\n    const bottom = y + height;\n    const dir = inset < 0 ? -inset : 0;\n    const size = Math.abs(inset);\n\n    return this\n        .moveTo(x, y + size)\n        .arcTo(x + dir, y + dir, x + size, y, size)\n        .lineTo(right - size, y)\n        .arcTo(right - dir, y + dir, right, y + size, size)\n        .lineTo(right, bottom - size)\n        .arcTo(right - dir, bottom - dir, x + width - size, bottom, size)\n        .lineTo(x + size, bottom)\n        .arcTo(x + dir, bottom - dir, x, bottom - size, size)\n        .closePath();\n}\n"],"names":[],"mappings":"AAgBO,SAAS,eACZ,GACA,GACA,OACA,QACA,QACJ;AACI,MAAI,WAAW;AAEX,WAAO,KAAK,SAAS,GAAG,GAAG,OAAO,MAAM;AAG5C,QAAM,YAAY,KAAK,IAAI,OAAO,MAAM,IAAI,GACtC,QAAQ,KAAK,IAAI,WAAW,KAAK,IAAI,CAAC,WAAW,MAAM,CAAC,GACxD,QAAQ,IAAI,OACZ,SAAS,IAAI,QACb,MAAM,QAAQ,IAAI,CAAC,QAAQ,GAC3B,OAAO,KAAK,IAAI,KAAK;AAE3B,SAAO,KACF,OAAO,GAAG,IAAI,IAAI,EAClB,MAAM,IAAI,KAAK,IAAI,KAAK,IAAI,MAAM,GAAG,IAAI,EACzC,OAAO,QAAQ,MAAM,CAAC,EACtB,MAAM,QAAQ,KAAK,IAAI,KAAK,OAAO,IAAI,MAAM,IAAI,EACjD,OAAO,OAAO,SAAS,IAAI,EAC3B,MAAM,QAAQ,KAAK,SAAS,KAAK,IAAI,QAAQ,MAAM,QAAQ,IAAI,EAC/D,OAAO,IAAI,MAAM,MAAM,EACvB,MAAM,IAAI,KAAK,SAAS,KAAK,GAAG,SAAS,MAAM,IAAI,EACnD,UAAU;AACnB;"}