1pub fn fit_to_rect(
7 r: tiny_skia::IntRect,
8 bounds: tiny_skia::IntRect,
9) -> Option<tiny_skia::IntRect> {
10 let mut left = r.left();
11 if left < bounds.left() {
12 left = bounds.left();
13 }
14
15 let mut top = r.top();
16 if top < bounds.top() {
17 top = bounds.top();
18 }
19
20 let mut right = r.right();
21 if right > bounds.right() {
22 right = bounds.right();
23 }
24
25 let mut bottom = r.bottom();
26 if bottom > bounds.bottom() {
27 bottom = bounds.bottom();
28 }
29
30 tiny_skia::IntRect::from_ltrb(left, top, right, bottom)
31}