{"version":3,"file":"drawStar.mjs","sources":["../src/drawStar.ts"],"sourcesContent":["import { PI_2, Polygon } from '@pixi/core';\n\nimport type { Graphics } from '@pixi/graphics';\n\n/**\n * Draw a star shape with an arbitrary number of points.\n * @ignore\n */\nclass Star extends Polygon\n{\n    /**\n     * @param x - Center X position of the star\n     * @param y - Center Y position of the star\n     * @param points - The number of points of the star, must be > 1\n     * @param radius - The outer radius of the star\n     * @param innerRadius - The inner radius between points, default half `radius`\n     * @param rotation - The rotation of the star in radians, where 0 is vertical\n     */\n    constructor(x: number, y: number, points: number, radius: number, innerRadius?: number, rotation = 0)\n    {\n        innerRadius = innerRadius || radius / 2;\n\n        const startAngle = (-1 * Math.PI / 2) + rotation;\n        const len = points * 2;\n        const delta = PI_2 / len;\n        const polygon = [];\n\n        for (let i = 0; i < len; i++)\n        {\n            const r = i % 2 ? innerRadius : radius;\n            const angle = (i * delta) + startAngle;\n\n            polygon.push(\n                x + (r * Math.cos(angle)),\n                y + (r * Math.sin(angle))\n            );\n        }\n\n        super(polygon);\n    }\n}\n\n/**\n * Draw a star shape with an arbitrary number of points.\n *\n * _Note: Only available with **@pixi/graphics-extras**._\n * @method PIXI.Graphics#drawStar\n * @param this\n * @param x - Center X position of the star\n * @param y - Center Y position of the star\n * @param points - The number of points of the star, must be > 1\n * @param radius - The outer radius of the star\n * @param innerRadius - The inner radius between points, default half `radius`\n * @param rotation - The rotation of the star in radians, where 0 is vertical\n * @returns - This Graphics object. Good for chaining method calls\n */\nexport function drawStar(this: Graphics,\n    x: number,\n    y: number,\n    points: number,\n    radius: number,\n    innerRadius: number,\n    rotation = 0): Graphics\n{\n    return this.drawPolygon(new Star(x, y, points, radius, innerRadius, rotation) as Polygon);\n}\n"],"names":[],"mappings":";AAQA,MAAM,aAAa,QACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASI,YAAY,GAAW,GAAW,QAAgB,QAAgB,aAAsB,WAAW,GACnG;AACI,kBAAc,eAAe,SAAS;AAEtC,UAAM,aAAc,KAAK,KAAK,KAAK,IAAK,UAClC,MAAM,SAAS,GACf,QAAQ,OAAO,KACf,UAAU;AAEhB,aAAS,IAAI,GAAG,IAAI,KAAK,KACzB;AACI,YAAM,IAAI,IAAI,IAAI,cAAc,QAC1B,QAAS,IAAI,QAAS;AAEpB,cAAA;AAAA,QACJ,IAAK,IAAI,KAAK,IAAI,KAAK;AAAA,QACvB,IAAK,IAAI,KAAK,IAAI,KAAK;AAAA,MAAA;AAAA,IAE/B;AAEA,UAAM,OAAO;AAAA,EACjB;AACJ;AAgBO,SAAS,SACZ,GACA,GACA,QACA,QACA,aACA,WAAW,GACf;AACW,SAAA,KAAK,YAAY,IAAI,KAAK,GAAG,GAAG,QAAQ,QAAQ,aAAa,QAAQ,CAAY;AAC5F;"}