rusty_vision/geometry/shape.rs
1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2pub struct Shape {
3 pub width: usize,
4 pub height: usize,
5 pub ndim: usize,
6}
7
8impl Shape {
9 pub fn new(width: usize, height: usize, ndim: Option<usize>) -> Shape {
10 let ndim = ndim.unwrap_or(1);
11
12 Shape {
13 width,
14 height,
15 ndim,
16 }
17 }
18
19 pub fn size(&self) -> usize {
20 self.width * self.height * self.ndim
21 }
22}