Debian Codegraph @

README.md

raw symbols SCIP
1 # Line clipping
2
3 [![crate-badge]][crate]
4 [![docs-badge]][docs]
5 [![license-badge]][license] \
6 [![github-badge]][github]
7 [![build-badge]][build]
8 [![codecov-badge]][codecov]
9
10 [crate-badge]: https://img.shields.io/crates/v/line-clipping?logo=rust
11 [docs-badge]: https://img.shields.io/badge/docs.rs-line_clipping-blue?logo=rust
12 [license-badge]: https://img.shields.io/crates/l/line-clipping?logo=apache
13 [github-badge]: https://img.shields.io/badge/github-joshka%2Fline_clipping-blue?logo=github
14 [build-badge]: https://github.com/joshka/line-clipping/actions/workflows/ci.yml/badge.svg?logo=github
15 [codecov-badge]: https://img.shields.io/codecov/c/github/joshka/line-clipping?logo=codecov
16
17 [github]: https://github.com/joshka/line-clipping
18 [crate]: https://crates.io/crates/line-clipping
19 [license]: #license
20 [docs]: https://docs.rs/line-clipping
21 [build]: https://github.com/joshka/line-clipping/actions/workflows/ci.yml
22 [codecov]: https://codecov.io/gh/joshka/line-clipping
23
24 <!-- cargo-rdme start -->
25
26 A rust crate to implement several line clipping algorithms. See the
27 [documentation](https://docs.rs/line_clipping) for more information. The choice of algorithms is
28 based on the following article which contains a good summary of the options:
29
30 Matthes D, Drakopoulos V. [Line Clipping in 2D: Overview, Techniques and
31 Algorithms](https://pmc.ncbi.nlm.nih.gov/articles/PMC9605407/). J Imaging. 2022 Oct
32 17;8(10):286. doi: 10.3390/jimaging8100286. PMID: 36286380; PMCID: PMC9605407.
33
34 Supports:
35
36 - [x] [Cohen-Sutherland](https://docs.rs/line-clipping/latest/line_clipping/cohen_sutherland/)
37
38 TODO
39
40 - [ ] Cyrus-Beck
41 - [ ] Liang-Barsky
42 - [ ] Nicholl-Lee-Nicholl
43 - [ ] More comprehensive testing
44
45 ## Installation
46
47 ```shell
48 cargo add line-clipping
49 ```
50
51 ## Minimum supported Rust version
52
53 The crate is built with Rust 1.85 to match the 2024 edition. The MSRV may increase in a
54 future minor release, but will be noted in the changelog.
55
56 ## Usage
57
58 ```rust
59 use line_clipping::cohen_sutherland::clip_line;
60 use line_clipping::{LineSegment, Point, Window};
61
62 let line = LineSegment::new(Point::new(-10.0, -10.0), Point::new(20.0, 20.0));
63 let window = Window::new(0.0, 10.0, 0.0, 10.0);
64 let clipped_line = clip_line(line, window);
65 ```
66
67 ## License
68
69 Copyright (c) Josh McKinney
70
71 This project is licensed under either of
72
73 - MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
74 - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
75
76 at your option.
77
78 ## Contribution
79
80 Contributions are welcome! Please open an issue or submit a pull request.
81
82 Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in
83 the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without
84 any additional terms or conditions.
85
86 <!-- cargo-rdme end -->