{"version":3,"file":"drawFilletRect.mjs","sources":["../src/drawFilletRect.ts"],"sourcesContent":["import type { Graphics } from 'pixijs/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 **pixijs/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,SAAA,cAAA,CACH,CACA,EAAA,CAAA,EACA,KACA,EAAA,MAAA,EACA,MACJ,EAAA;AACI,EAAA,IAAI,WAAW,CACf,EAAA;AACI,IAAA,OAAO,IAAK,CAAA,QAAA,CAAS,CAAG,EAAA,CAAA,EAAG,OAAO,MAAM,CAAA,CAAA;AAAA,GAC5C;AAEA,EAAA,MAAM,SAAY,GAAA,IAAA,CAAK,GAAI,CAAA,KAAA,EAAO,MAAM,CAAI,GAAA,CAAA,CAAA;AAC5C,EAAM,MAAA,KAAA,GAAQ,KAAK,GAA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