jiao/core/line_clipper.rs
1// Copyright (c) 2023 Xu Shaohua <shaohua@biofan.org>. All rights reserved.
2// Use of this source is governed by Lesser General Public License that can be found
3// in the LICENSE file.
4
5use crate::core::point::Point;
6use crate::core::rect::Rect;
7
8pub const MAX_POINTS: usize = 4;
9pub const MAX_LIPPED_LINE_SEGMENTS: usize = MAX_POINTS - 1;
10
11/// Clip the line pts[0]...pts[1] against clip, ignoring segments that
12/// lie completely above or below the clip.
13///
14/// For portions to the left or right, turn those into vertical line segments
15/// that are aligned to the edge of the clip.
16///
17/// Return the number of line segments that result, and store the end-points
18/// of those segments sequentially in lines as follows:
19/// - 1st segment: lines[0]..lines[1]
20/// - 2nd segment: lines[1]..lines[2]
21/// - 3rd segment: lines[2]..lines[3]
22#[must_use]
23pub fn clip_line(
24 _pts: &[Point; 2],
25 _clip: &Rect,
26 _lines: &mut [Point; MAX_POINTS],
27 _can_cull_to_the_right: bool,
28) -> i32 {
29 unimplemented!()
30}
31
32/// Intersect the line segment against the rect.
33///
34/// If there is a non-empty resulting segment, return true and set dst[] to that segment.
35/// If not, return false and ignore dst[].
36///
37/// `clip_line()` is specialized for scan-conversion, as it adds vertical
38/// segments on the sides to show where the line extended beyond the
39/// left or right sides. `intersect_line()` does not.
40#[must_use]
41pub fn intersect_line(_src: &[Point; 2], _clip: &Rect, _dst: &mut Point) -> bool {
42 unimplemented!()
43}