lineseg
v0.2.0
Published
Cut a line segment into multiple segments of equal length. Born in [maptalks.three](https://github.com/maptalks/maptalks.three)
Readme
lineseg
Cut a line segment into multiple segments of equal length. Born in maptalks.three
DEMO
Install
NPM
npm i linese
#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>