File: README.md

package info (click to toggle)
rust-line-clipping 0.3.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 168 kB
  • sloc: makefile: 2
file content (86 lines) | stat: -rw-r--r-- 2,857 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Line clipping

[![crate-badge]][crate]
[![docs-badge]][docs]
[![license-badge]][license] \
[![github-badge]][github]
[![build-badge]][build]
[![codecov-badge]][codecov]

[crate-badge]: https://img.shields.io/crates/v/line-clipping?logo=rust
[docs-badge]: https://img.shields.io/badge/docs.rs-line_clipping-blue?logo=rust
[license-badge]: https://img.shields.io/crates/l/line-clipping?logo=apache
[github-badge]: https://img.shields.io/badge/github-joshka%2Fline_clipping-blue?logo=github
[build-badge]: https://github.com/joshka/line-clipping/actions/workflows/ci.yml/badge.svg?logo=github
[codecov-badge]: https://img.shields.io/codecov/c/github/joshka/line-clipping?logo=codecov

[github]: https://github.com/joshka/line-clipping
[crate]: https://crates.io/crates/line-clipping
[license]: #license
[docs]: https://docs.rs/line-clipping
[build]: https://github.com/joshka/line-clipping/actions/workflows/ci.yml
[codecov]: https://codecov.io/gh/joshka/line-clipping

<!-- cargo-rdme start -->

A rust crate to implement several line clipping algorithms. See the
[documentation](https://docs.rs/line_clipping) for more information. The choice of algorithms is
based on the following article which contains a good summary of the options:

Matthes D, Drakopoulos V. [Line Clipping in 2D: Overview, Techniques and
Algorithms](https://pmc.ncbi.nlm.nih.gov/articles/PMC9605407/). J Imaging. 2022 Oct
17;8(10):286. doi: 10.3390/jimaging8100286. PMID: 36286380; PMCID: PMC9605407.

Supports:

- [x] [Cohen-Sutherland](https://docs.rs/line-clipping/latest/line_clipping/cohen_sutherland/)

TODO

- [ ] Cyrus-Beck
- [ ] Liang-Barsky
- [ ] Nicholl-Lee-Nicholl
- [ ] More comprehensive testing

## Installation

```shell
cargo add line-clipping
```

## Minimum supported Rust version

The crate is built with Rust 1.85 to match the 2024 edition. The MSRV may increase in a
future minor release, but will be noted in the changelog.

## Usage

```rust
use line_clipping::cohen_sutherland::clip_line;
use line_clipping::{LineSegment, Point, Window};

let line = LineSegment::new(Point::new(-10.0, -10.0), Point::new(20.0, 20.0));
let window = Window::new(0.0, 10.0, 0.0, 10.0);
let clipped_line = clip_line(line, window);
```

## License

Copyright (c) Josh McKinney

This project is licensed under either of

- MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)

at your option.

## Contribution

Contributions are welcome! Please open an issue or submit a pull request.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in
the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without
any additional terms or conditions.

<!-- cargo-rdme end -->