modeling/src/primitives/line.js

  1. const path2 = require('../geometries/path2')
  2. /**
  3. * Construct a new line in two dimensional space from the given points.
  4. * The points must be provided as an array, where each element is a 2D point.
  5. * @param {Array} points - array of points from which to create the path
  6. * @returns {path2} new 2D path
  7. * @alias module:modeling/primitives.line
  8. *
  9. * @example
  10. * let myshape = line([[10, 10], [-10, 10]])
  11. */
  12. const line = (points) => {
  13. if (!Array.isArray(points)) throw new Error('points must be an array')
  14. return path2.fromPoints({}, points)
  15. }
  16. module.exports = line