GithubHelp home page GithubHelp logo

isabella232 / lineclip Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mapbox/lineclip

0.0 0.0 0.0 21 KB

A very fast JavaScript polyline and polygon clipping library

License: ISC License

JavaScript 100.00%

lineclip's Introduction

lineclip

Build Status Coverage Status

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

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

API

lineclip.polyline(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.

lineclip.polygon(points, bbox)

Returns a clipped polygon.

Install

Install with NPM:

npm install lineclip

To build a browser-compatible version, clone the repository locally, then run:

npm install -g browserify
browserify -s lineclip index.js > lineclip.js

Changelog

1.1.5 (Sep 23, 2015)

  • Fixed a bug where polygon clip broke on out-of-bbox polygons.

1.1.4 (Sep 22, 2015)

  • Fixed a bug where last point was omitted if the last two points are in bbox.
  • Fixed a bug where a line outside of bbox would produce [[]] instead of [].

1.1.3 (Sep 12, 2015)

  • Fixed a polygon clipping race condition.

1.1.2 (Sep 11, 2015)

  • Fixed a bug that completely broke the clipping on many cases. Sorry!

1.1.1 (Sep 11, 2015)

  • Fixed a polyline clipping edge case.

1.1.0 (Sep 11, 2015)

  • Added Sutherland-Hodgeman polygon clipping (lineclip.polygon).

1.0.1 (Sep 11, 2015)

  • Minor code cleanup and optimizations.

1.0.0 (Sep 8, 2015)

  • Initial release.

lineclip's People

Contributors

brianreavis avatar deniscarriere avatar mourner avatar tcql avatar tmcw avatar waldyrious avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.