mapbox/lineclip

A very fast JavaScript polyline and polygon clipping library

JavaScript

184

47 commits

updated Jul 12, 2026

See the code

README

lineclip Simply Awesome

A very fast JavaScript library for clipping polylines and polygons by a bounding box.

import {clipPolyline} from 'lineclip';

clipPolyline(
    [[-10, 10], [10, 10], [10, -10]], // line
    [0, 0, 20, 20]); // bbox
// returns [[[0, 10], [10, 10], [10, 0]]]

API

clipPolyline(points, bbox[, result])

  • points — an array of [x, y] points
  • bbox — a bounding box as [xmin, ymin, xmax, ymax]
  • result — an array to append the results to

Returns an array of clipped lines.

lineclip is an alias to lineclip.polyline.

clipPolygon(points, bbox)

Returns a clipped polygon.

mapbox/lineclip

A very fast JavaScript polyline and polygon clipping library

JavaScript

184

47 commits

updated Jul 12, 2026

See the code

README

lineclip Simply Awesome

A very fast JavaScript library for clipping polylines and polygons by a bounding box.

import {clipPolyline} from 'lineclip';

clipPolyline(
    [[-10, 10], [10, 10], [10, -10]], // line
    [0, 0, 20, 20]); // bbox
// returns [[[0, 10], [10, 10], [10, 0]]]

API

clipPolyline(points, bbox[, result])

  • points — an array of [x, y] points
  • bbox — a bounding box as [xmin, ymin, xmax, ymax]
  • result — an array to append the results to

Returns an array of clipped lines.

lineclip is an alias to lineclip.polyline.

clipPolygon(points, bbox)

Returns a clipped polygon.

Project health

Overall

4.7/10

Maintained

0/10

Code review

1/10
OpenSSF Scorecard

Latest release

2.0.0 · Jul 16, 2025

Releases this year

0

Significant stargazers

Matt DesLauriers

7,377 followers · starred Mar 2017

Ian Storm Taylor

3,028 followers · starred May 2022

Brandon Dail

1,874 followers · starred Aug 2021

hujiulong

796 followers · starred Jan 2020