lineseg
v0.0.2
Published
Cut a line segment into multiple segments of equal length. Born in [maptalks.three](https://github.com/maptalks/maptalks.three)
Downloads
2
Readme
lineseg
Cut a line segment into multiple segments of equal length. Born in maptalks.three
install
NPM
npm i lineseg
#or
yarn add lineseg
#or
pnpm i lineseg
CDN
<script
type="text/javascript"
src="https://unpkg.com/lineseg/dist/lineseg.js"
></script>
API
- lineSeg(line,options)
line
, Collection of points,such as [[x,y],[x,y],[xy],.......];options.segDistance
, per seg lengthoptions.isGeo
,Is it geographical coordinates
ESM
//ESM
import {
lineSeg
} from "lineseg";
const line = [
[x, y],
[x, y],
[x, y],
[x, y],
[x, y], ..........
];
const seg = lineSeg(line, {
segDistance: 100,// per seg length
isGeo: true //Is it geographical coordinates
})
nodejs
//nodejs
const {lineSeg} = require("lineseg");
const line = [
[x, y],
[x, y],
[x, y],
[x, y],
[x, y], ..........
];
const seg = lineSeg(line, {
segDistance: 100,// per seg length
isGeo: true //Is it geographical coordinates
})
CDN
<script
type="text/javascript"
src="https://unpkg.com/lineseg/dist/lineseg.js"
></script>
<script>
const line = [
[x, y],
[x, y],
[x, y],
[x, y],
[x, y], ..........
];
const segs = lineseg.lineSeg(line, { segDistance: 100 });
</script>