pub fn calculate_points_for_rect<P: Into<Pt>>(
    scale_x: P,
    scale_y: P,
    offset_x: P,
    offset_y: P
) -> Vec<(Point, bool)>
Expand description

Calculates and returns the points for a rectangle, given a horizontal and vertical scale. and an offset into the centre of rectangle (starting from bottom left corner of page).

Examples found in repository?
examples/circle.rs (lines 35-40)
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
fn main() {
    let (doc, page1, layer1) =
        PdfDocument::new("printpdf circle test", Mm(210.0), Mm(297.0), "Layer 1");
    let current_layer = doc.get_page(page1).get_layer(layer1);

    let radius_1 = Pt(40.0);
    let radius_2 = Pt(30.0);
    let offset_x = Pt(10.0);
    let offset_y = Pt(50.0);

    let line = Polygon {
        rings: vec![
            calculate_points_for_circle(radius_1, offset_x, offset_y),
            calculate_points_for_circle(radius_2, offset_x, offset_y), // hole
        ],
        mode: PaintMode::FillStroke,
        winding_order: WindingOrder::EvenOdd,
    };

    current_layer.add_polygon(line);

    let scale_x_rect = Pt(40.0);
    let scale_y_rect = Pt(10.0);
    let offset_x_rect = Pt(20.0);
    let offset_y_rect = Pt(5.0);

    let line = Polygon {
        rings: vec![calculate_points_for_rect(
            scale_x_rect,
            scale_y_rect,
            offset_x_rect,
            offset_y_rect,
        )],
        mode: PaintMode::FillStroke,
        winding_order: WindingOrder::NonZero,
    };

    current_layer.add_polygon(line);

    doc.save(&mut BufWriter::new(
        File::create("test_circle.pdf").unwrap(),
    ))
    .unwrap();
}