pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
28 lines (25 loc) • 741 B
JavaScript
;
;
function buildArc(points, x, y, radius, start, end, clockwise, steps) {
let dist = Math.abs(start - end);
if (!clockwise && start > end) {
dist = 2 * Math.PI - dist;
} else if (clockwise && end > start) {
dist = 2 * Math.PI - dist;
}
steps || (steps = Math.max(6, Math.floor(6 * Math.pow(radius, 1 / 3) * (dist / Math.PI))));
steps = Math.max(steps, 3);
let f = dist / steps;
let t = start;
f *= clockwise ? -1 : 1;
for (let i = 0; i < steps + 1; i++) {
const cs = Math.cos(t);
const sn = Math.sin(t);
const nx = x + cs * radius;
const ny = y + sn * radius;
points.push(nx, ny);
t += f;
}
}
exports.buildArc = buildArc;
//# sourceMappingURL=buildArc.js.map