Coverage Report

Created: 2025-12-28 06:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/plotters-backend-0.3.7/src/rasterizer/rect.rs
Line
Count
Source
1
use crate::{BackendCoord, BackendStyle, DrawingBackend, DrawingErrorKind};
2
3
0
pub fn draw_rect<B: DrawingBackend, S: BackendStyle>(
4
0
    b: &mut B,
5
0
    upper_left: BackendCoord,
6
0
    bottom_right: BackendCoord,
7
0
    style: &S,
8
0
    fill: bool,
9
0
) -> Result<(), DrawingErrorKind<B::ErrorType>> {
10
0
    if style.color().alpha == 0.0 {
11
0
        return Ok(());
12
0
    }
13
0
    let (upper_left, bottom_right) = (
14
0
        (
15
0
            upper_left.0.min(bottom_right.0),
16
0
            upper_left.1.min(bottom_right.1),
17
0
        ),
18
0
        (
19
0
            upper_left.0.max(bottom_right.0),
20
0
            upper_left.1.max(bottom_right.1),
21
0
        ),
22
0
    );
23
24
0
    if fill {
25
0
        if bottom_right.0 - upper_left.0 < bottom_right.1 - upper_left.1 {
26
0
            for x in upper_left.0..=bottom_right.0 {
27
0
                check_result!(b.draw_line((x, upper_left.1), (x, bottom_right.1), style));
28
            }
29
        } else {
30
0
            for y in upper_left.1..=bottom_right.1 {
31
0
                check_result!(b.draw_line((upper_left.0, y), (bottom_right.0, y), style));
32
            }
33
        }
34
    } else {
35
0
        b.draw_line(
36
0
            (upper_left.0, upper_left.1),
37
0
            (upper_left.0, bottom_right.1),
38
0
            style,
39
0
        )?;
40
0
        b.draw_line(
41
0
            (upper_left.0, upper_left.1),
42
0
            (bottom_right.0, upper_left.1),
43
0
            style,
44
0
        )?;
45
0
        b.draw_line(
46
0
            (bottom_right.0, bottom_right.1),
47
0
            (upper_left.0, bottom_right.1),
48
0
            style,
49
0
        )?;
50
0
        b.draw_line(
51
0
            (bottom_right.0, bottom_right.1),
52
0
            (bottom_right.0, upper_left.1),
53
0
            style,
54
0
        )?;
55
    }
56
0
    Ok(())
57
0
}