UNPKG

d3plus-shape

Version:

Fancy SVG shapes for visualizations

16 lines (15 loc) 638 B
import pointRotate from "./pointRotate.js"; /** @function polygonRotate @desc Rotates a point around a given origin. @param {Array} poly The polygon to be rotated, which should be an Array of `[x, y]` values. @param {Number} alpha The angle in radians to rotate. @param {Array} [origin = [0, 0]] The origin point of the rotation, which should be an `[x, y]` formatted Array. @returns {Boolean} */ export default (function (poly, alpha) { var origin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [0, 0]; return poly.map(function (p) { return pointRotate(p, alpha, origin); }); });