Skip to content

Latest commit

 

History

History

geom-clip-line

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

geom-clip-line

npm version npm downloads Twitter Follow

This project is part of the @thi.ng/umbrella monorepo.

About

2D line clipping (Liang-Barsky). This is a support package for @thi.ng/geom.

Current implementation is based on toxiclibs (Java) and Clojure version thi.ng/geom-clj.

This package has been extracted from the former (now obsolete) @thi.ng/geom-clip package.

Status

STABLE - used in production

Search or submit any issues for this package

Related packages

Installation

yarn add @thi.ng/geom-clip-line

ES module import:

<script type="module" src="https://cdn.skypack.dev/@thi.ng/geom-clip-line"></script>

Skypack documentation

For NodeJS (v14.6+):

node --experimental-specifier-resolution=node --experimental-repl-await

> const geomClipLine = await import("@thi.ng/geom-clip-line");

Package sizes (gzipped, pre-treeshake): ESM: 549 bytes

Dependencies

API

Generated API docs

  • liangBarsky2
  • liangBarksy2Raw
import { liangBarsky2 } from "@thi.ng/geom-clip-line";

liangBarsky2(
    // line end points
    [-10, -20], [30, 400],
    // min/max clip rect
    [0, 0], [100, 200]
)
// [ [ 0, 85 ], [ 10.952380952380953, 200 ], 0.25, 0.5238095238095238 ]

// returns undefined if line is completely outside the clip rect
liangBarsky2(
    // line end points
    [-10, -20], [-30, 400],
    // min/max bbox
    [0, 0], [100, 200]
)
// undefined

Authors

Karsten Schmidt

If this project contributes to an academic publication, please cite it as:

@misc{thing-geom-clip-line,
  title = "@thi.ng/geom-clip-line",
  author = "Karsten Schmidt",
  note = "https://thi.ng/geom-clip-line",
  year = 2013
}

License

© 2013 - 2021 Karsten Schmidt // Apache Software License 2.0