{"version":3,"file":"drawChamferRect.mjs","sources":["../src/drawChamferRect.ts"],"sourcesContent":["import type { Graphics } from '@pixi/graphics';\n\n/**\n * Draw Rectangle with chamfer corners. These are angled corners.\n *\n * _Note: Only available with **@pixi/graphics-extras**._\n * @method PIXI.Graphics#drawChamferRect\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} chamfer - non-zero real number, size of corner cutout\n * @returns {PIXI.Graphics} Returns self.\n */\nexport function drawChamferRect(this: Graphics,\n    x: number,\n    y: number,\n    width: number,\n    height: number,\n    chamfer: number): Graphics\n{\n    if (chamfer <= 0)\n    {\n        return this.drawRect(x, y, width, height);\n    }\n\n    const inset = Math.min(chamfer, Math.min(width, height) / 2);\n    const right = x + width;\n    const bottom = y + height;\n    const points = [\n        x + inset, y,\n        right - inset, y,\n        right, y + inset,\n        right, bottom - inset,\n        right - inset, bottom,\n        x + inset, bottom,\n        x, bottom - inset,\n        x, y + inset,\n    ];\n\n    // Remove overlapping points\n    for (let i = points.length - 1; i >= 2; i -= 2)\n    {\n        if (points[i] === points[i - 2] && points[i - 1] === points[i - 3])\n        {\n            points.splice(i - 1, 2);\n        }\n    }\n\n    return this.drawPolygon(points);\n}\n"],"names":[],"mappings":"AAeO,SAAS,gBACZ,GACA,GACA,OACA,QACA,SACJ;AACI,MAAI,WAAW;AAEX,WAAO,KAAK,SAAS,GAAG,GAAG,OAAO,MAAM;AAG5C,QAAM,QAAQ,KAAK,IAAI,SAAS,KAAK,IAAI,OAAO,MAAM,IAAI,CAAC,GACrD,QAAQ,IAAI,OACZ,SAAS,IAAI,QACb,SAAS;AAAA,IACX,IAAI;AAAA,IAAO;AAAA,IACX,QAAQ;AAAA,IAAO;AAAA,IACf;AAAA,IAAO,IAAI;AAAA,IACX;AAAA,IAAO,SAAS;AAAA,IAChB,QAAQ;AAAA,IAAO;AAAA,IACf,IAAI;AAAA,IAAO;AAAA,IACX;AAAA,IAAG,SAAS;AAAA,IACZ;AAAA,IAAG,IAAI;AAAA,EAAA;AAIX,WAAS,IAAI,OAAO,SAAS,GAAG,KAAK,GAAG,KAAK;AAErC,WAAO,CAAC,MAAM,OAAO,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,MAAM,OAAO,IAAI,CAAC,KAE7D,OAAO,OAAO,IAAI,GAAG,CAAC;AAIvB,SAAA,KAAK,YAAY,MAAM;AAClC;"}