pub struct Shape {
pub orow: usize,
pub ocol: usize,
pub colour: Colour,
pub cells: Matrix<Cell>,
}Fields§
§orow: usize§ocol: usize§colour: Colour§cells: Matrix<Cell>Implementations§
Source§impl Shape
impl Shape
pub fn new(orow: usize, ocol: usize, cells: &Matrix<Cell>) -> Self
pub fn new_cells(cells: &Matrix<Cell>) -> Self
pub fn new_sized_coloured(rows: usize, cols: usize, colour: Colour) -> Self
pub fn new_sized_coloured_position( orow: usize, ocol: usize, row: usize, col: usize, colour: Colour, ) -> Self
pub fn new_empty() -> Self
pub fn trivial() -> Self
pub fn new9(&self, corners: bool, colour: Colour) -> Self
pub fn is_full(&self) -> bool
pub fn corners(&self) -> (usize, usize, usize, usize)
pub fn same_patch(&self, other: &Self) -> bool
pub fn fill(&self, other: &Self) -> Self
pub fn make_symmetric(&self) -> Self
pub fn col_symmetric_mut(&self, shapes: &mut Shapes)
pub fn new_square(r: usize, c: usize, size: usize, colour: Colour) -> Self
pub fn is_trivial(&self) -> bool
pub fn remove(&mut self, c: &Cell)
pub fn to_shapes(&self) -> Shapes
pub fn to_shapes_coloured(&self) -> Shapes
pub fn to_shapes_base(&self, coloured: bool) -> Shapes
pub fn pixels_in_shape(&self) -> usize
pub fn shrink_any(&self, coloured: bool) -> Self
pub fn remove_border(&self) -> Self
pub fn remove_ragged_left(&self) -> Self
pub fn remove_ragged_right(&self) -> Self
pub fn remove_ragged_top(&self) -> Self
pub fn remove_ragged_bottom(&self) -> Self
pub fn has_ragged_left(&self) -> bool
pub fn has_ragged_right(&self) -> bool
pub fn has_ragged_top(&self) -> bool
pub fn has_ragged_bottom(&self) -> bool
pub fn remove_ragged_border(&self) -> Self
pub fn find_colour_pixel_coords(&self, colour: Colour) -> (usize, usize)
pub fn find_different_pixel_coords(&self) -> (usize, usize)
pub fn find_distinct_colours(&self, bg: Colour) -> Vec<Cell>
pub fn shrink_border(&self) -> Self
pub fn shrink_border_n(&self, n: usize) -> Self
pub fn shrink_border_colour(&self, bg: Colour) -> Self
pub fn shrink_border_colour_n(&self, bg: Colour, n: usize) -> Self
pub fn shrink_left(&self, n: usize) -> Self
pub fn on_edge(&self, grid: &Grid) -> bool
pub fn find_same_row(&self, others: &[Self]) -> Self
pub fn find_same_col(&self, others: &[Self]) -> Self
pub fn shrink(&self) -> Self
pub fn shrink_coloured(&self) -> Self
pub fn euclidian(&self, other: &Self) -> f64
pub fn manhattan(&self, other: &Self) -> usize
pub fn is_diagonal(&self, other: &Self) -> bool
pub fn which_direction(&self, other: &Self) -> Direction
pub fn is_pixel(&self) -> bool
pub fn fill_boundary_colour(&self) -> Self
pub fn fill_boundary_colour_bg(&self, bg: Colour) -> Self
pub fn flood_fill_border_mut( &mut self, ignore_colour: Colour, new_colour: Colour, )
pub fn flood_fill( &self, r: usize, c: usize, ignore_colour: Colour, new_colour: Colour, ) -> Self
pub fn flood_fill_mut( &mut self, r: usize, c: usize, ignore_colour: Colour, new_colour: Colour, )
pub fn sid(m: &Matrix<Cell>, coloured: bool) -> u32
pub fn contains_colour(&self, colour: Colour) -> bool
pub fn has_bg_grid(&self) -> Colour
pub fn has_bg_grid_coloured(&self) -> Colour
pub fn has_bg_grid_not_sq(&self) -> Colour
pub fn has_bg_grid_coloured_not_sq(&self) -> Colour
pub fn gravity_down(&self) -> Self
pub fn gravity_down_colour(&self, colour: Colour) -> Self
pub fn gravity_up(&self) -> Self
pub fn gravity_up_colour(&self, colour: Colour) -> Self
pub fn gravity_right(&self) -> Self
pub fn gravity_right_colour(&self, colour: Colour) -> Self
pub fn gravity_left(&self) -> Self
pub fn gravity_left_colour(&self, colour: Colour) -> Self
pub fn equals(&self, other: &Self) -> Colour
pub fn find_equals(&self, shapes: &Shapes) -> Shape
pub fn equal_position(&self, other: &Self) -> bool
pub fn find_equal_position(&self, shapes: &Shapes) -> Shape
pub fn equal_footprint(&self, other: &Self) -> bool
pub fn find_equal_footprint(&self, shapes: &Shapes) -> Shape
pub fn equal_shape(&self, other: &Self) -> bool
pub fn find_equal_shape(&self, shapes: &Shapes) -> Shape
pub fn show_summary(&self)
pub fn show(&self)
pub fn show_full(&self)
pub fn show_out(&self)
pub fn show_io(&self)
pub fn is_empty(&self) -> bool
pub fn subshape_remain( &self, tlr: usize, sr: usize, tlc: usize, sc: usize, ) -> Self
pub fn subshape(&self, tlr: usize, sr: usize, tlc: usize, sc: usize) -> Self
pub fn subshape_trim( &self, tlr: usize, sr: usize, tlc: usize, sc: usize, ) -> Self
pub fn id(&self) -> String
pub fn above(&self, other: &Self) -> bool
pub fn below(&self, other: &Self) -> bool
pub fn right(&self, other: &Self) -> bool
pub fn left(&self, other: &Self) -> bool
pub fn diag(&self, other: &Self) -> bool
pub fn orientation_horizontal(&self) -> Option<bool>
pub fn size(&self) -> usize
pub fn width(&self) -> usize
pub fn height(&self) -> usize
pub fn origin(&self) -> (usize, usize)
pub fn pixels(&self) -> usize
pub fn same_size(&self, other: &Self) -> bool
pub fn same_shape(&self, other: &Self) -> bool
pub fn same_pixel_positions(&self, other: &Self, same_colour: bool) -> bool
pub fn dimensions(&self) -> (usize, usize)
pub fn density(&self) -> f32
pub fn distinct_colour_cnt(&self) -> usize
pub fn find_layers(&self) -> (usize, Colour, Vec<Direction>)
pub fn paint_layers_mut( &mut self, indent: usize, depth: usize, colour: Colour, dirs: Vec<Direction>, )
pub fn cell_colours(&self) -> Vec<Colour>
pub fn cell_colour_cnt_map(&self) -> BTreeMap<Colour, usize>
pub fn cell_colour_cnt(cells: &Matrix<Cell>, max: bool) -> (Colour, usize)
pub fn cell_colour_cnt_mixed( cells: &Matrix<Cell>, max: bool, mixed: bool, ) -> (Colour, usize)
pub fn colour_cnt(&self, max: bool) -> (Colour, usize)
pub fn majority_colour(&self) -> Colour
pub fn minority_colour(&self) -> Colour
pub fn colour_position(&self, colour: Colour) -> Vec<(usize, usize)>
pub fn origin_centre(&self) -> (usize, usize, usize, usize)
pub fn is_larger(&self, other: &Self) -> bool
pub fn is_smaller(&self, other: &Self) -> bool
pub fn larger(&self, other: &Self) -> Self
pub fn smaller(&self, other: &Self) -> Self
pub fn to_square(&self) -> Self
pub fn to_square_grid(&self) -> Grid
pub fn distance(&self, other: &Self) -> f32
pub fn distance_from(&self, row: usize, col: usize) -> f32
pub fn is_mirrored_r(&self, other: &Self) -> bool
pub fn is_mirrored_c(&self, other: &Self) -> bool
pub fn is_mirror_r(&self) -> bool
pub fn is_mirror_c(&self) -> bool
pub fn mirrored_r(&self) -> Self
pub fn mirrored_c(&self) -> Self
pub fn transposed(&self) -> Self
pub fn is_transposed(&self, other: &Self) -> bool
pub fn rotated_90(&self) -> Self
pub fn rotated_180(&self) -> Self
pub fn rotated_270(&self) -> Self
pub fn rot_rect_90(&self) -> Self
pub fn rot_rect_180(&self) -> Self
pub fn rot_rect_270(&self) -> Self
pub fn extend_line(&self) -> Self
pub fn is_rotated_90(&self, other: &Self) -> bool
pub fn is_rotated_180(&self, other: &Self) -> bool
pub fn is_rotated_270(&self, other: &Self) -> bool
pub fn rotate_90_pos(&self, times: usize, or: usize, oc: usize) -> Self
pub fn to_grid(&self) -> Grid
pub fn to_json(&self) -> String
pub fn cell_count(&self) -> usize
pub fn cell_count_colour(&self, colour: Colour) -> usize
pub fn corner_idx(&self) -> (Self, Direction)
pub fn corner_body(&self, dir: Direction) -> Self
pub fn split_4(&self) -> Vec<Self>
pub fn diff(&self, other: &Self) -> Option<Self>
pub fn diff_orig(&self, other: &Self) -> Option<Self>
pub fn diff_impl(&self, other: &Self, diff: bool) -> Option<Self>
pub fn diff_only_transparent(&self) -> Self
pub fn recolour(&self, from: Colour, to: Colour) -> Self
pub fn recolour_mut(&mut self, from: Colour, to: Colour)
pub fn force_recolour(&self, to: Colour) -> Self
pub fn force_recolour_mut(&mut self, to: Colour)
pub fn uncolour(&self) -> Self
pub fn uncolour_mut(&mut self)
pub fn is_line(&self) -> bool
pub fn is_horizontal_line(&self) -> bool
pub fn is_vertical_line(&self) -> bool
pub fn is_square(&self) -> bool
pub fn has_band(&self, rs: usize, cs: usize) -> (Direction, usize)
pub fn make_square(&self) -> Self
pub fn mut_recolour(&mut self, from: Colour, to: Colour)
pub fn mut_force_recolour(&mut self, to: Colour)
pub fn fill_missing(&self, to: Colour) -> Self
pub fn scale_up(&self, factor: usize) -> Self
pub fn scale_down(&self, factor: usize) -> Self
pub fn has_border_hole( &self, hole: bool, fc: &dyn Fn(usize, usize, usize, usize) -> bool, ) -> bool
pub fn has_border(&self) -> bool
pub fn is_hollow(&self) -> bool
pub fn has_open_border_top(&self) -> bool
pub fn has_open_hole_top(&self) -> bool
pub fn has_open_border_bottom(&self) -> bool
pub fn has_open_hole_bottom(&self) -> bool
pub fn has_open_border_left(&self) -> bool
pub fn has_open_hole_left(&self) -> bool
pub fn has_open_border_right(&self) -> bool
pub fn has_open_hole_right(&self) -> bool
pub fn find_a_border_break(&self) -> (Direction, usize, usize)
pub fn has_border_break(&self) -> (Direction, usize, usize)
pub fn centre_in(&self, other: &Self) -> Self
pub fn put_all_in(&mut self, other: &Self)
pub fn centre_of(&self) -> (usize, usize)
pub fn centre_of_exact(&self) -> (f32, f32)
pub fn nearest_point_idx(&self, points: &Vec<(usize, usize)>) -> usize
pub fn nearest_point(&self, points: &Vec<(usize, usize)>) -> (usize, usize)
pub fn pixel_coords(&self, colour: Colour) -> Option<(usize, usize)>
pub fn move_in(&self, other: &Self) -> Self
pub fn container(&self, other: &Self) -> bool
pub fn can_contain(&self, other: &Self) -> bool
pub fn contained_by(&self, other: &Self) -> bool
pub fn is_contained(&self, other: &Self) -> bool
pub fn contained_in(&self, other: &Self) -> bool
pub fn nest_mut(&mut self, n: usize, colour: Colour)
pub fn patch_in_shape(&self, other: &Self) -> (usize, usize)
pub fn adjacent_r_or_c(&self, other: &Self) -> bool
pub fn touching(&self, other: &Self) -> bool
pub fn find_touching(&self, shapes: &Shapes) -> Shape
pub fn single_colour(&self) -> Option<Colour>
pub fn is_single_colour(&self) -> bool
pub fn translate_row(&self, r: isize) -> Self
pub fn translate_col(&self, c: isize) -> Self
pub fn translate(&self, r: isize, c: isize) -> Self
pub fn translate_absolute_r(&self, r: usize) -> Self
pub fn translate_absolute_c(&self, c: usize) -> Self
pub fn translate_absolute(&self, r: usize, c: usize) -> Self
pub fn have_common_pixel_colour(&self, other: &Self) -> bool
pub fn merge_on_common_pixel(&self, other: &Self) -> Option<Self>
pub fn normalise(&self, si: &Self) -> (Self, Self)
pub fn normalise_key(&self) -> Self
pub fn bare_corners(&self) -> bool
pub fn fit_shape(&self, _shape: &Self) -> Self
pub fn to_origin(&self) -> Self
pub fn to_origin_mut(&mut self)
pub fn to_position(&self, r: usize, c: usize) -> Self
pub fn to_position_mut(&mut self, r: usize, c: usize)
pub fn compare(&self, shape: &Self) -> bool
pub fn copy_into(&self, shape: &Self) -> Self
pub fn position(&self, ci: &Self) -> Self
pub fn has_border_cell(&self, other: &Self) -> bool
pub fn is_subgrid(&self, other: &Self) -> bool
pub fn find_black_patches_limit(&self, limit: usize) -> Shapes
pub fn has_arm(&self, limit: usize) -> (Direction, usize)
pub fn bordered_shape(&self) -> bool
pub fn hollow(&self) -> bool
pub fn hollow_colour_count(&self) -> (Colour, usize)
pub fn full_shape(&self) -> bool
pub fn add_hugging_border(&self, colour: Colour) -> Self
pub fn add_border(&self, colour: Colour) -> Self
pub fn toddle_colour(&self, bg: Colour, fg: Colour) -> Self
pub fn extend_top(&self, n: usize) -> Self
pub fn extend_bottom(&self, n: usize) -> Self
pub fn extend_left(&self, n: usize) -> Self
pub fn extend_right(&self, n: usize) -> Self
pub fn dense(&self) -> bool
pub fn split_shapes(&self) -> Shapes
pub fn de_subshape(&self, shapes: &mut Shapes)
pub fn draw_line(&self, other: &Self, colour: Colour) -> Shape
pub fn fill_lines(&self, colour: Colour) -> Self
pub fn find_first_blacks(&self) -> Vec<(usize, usize)>
pub fn find_first_colours(&self, colour: Colour) -> Vec<(usize, usize)>
pub fn surround( &self, thickness: usize, colour: Colour, all: bool, corners: bool, ) -> Self
pub fn bg_count(&self) -> usize
pub fn split_2(&self) -> Shapes
pub fn cell_category(cells: &Matrix<Cell>) -> Matrix<Cell>
pub fn cell_category_bg(cells: &Matrix<Cell>, bg: Colour) -> Matrix<Cell>
pub fn fill_corners_mut(&mut self, pixels: usize, colour: Colour)
pub fn pixel_position(&self, min_colour: Colour) -> Direction
pub fn chequer( &self, rows: usize, cols: usize, pred: &dyn Fn(usize, usize) -> bool, func: &dyn Fn(&Self) -> Self, blank: bool, ) -> Shapes
pub fn combined_chequer( &self, rows: usize, cols: usize, func: &dyn Fn(&Self, usize, usize) -> Self, ) -> Shapes
pub fn fit_chequer( &self, rc: usize, cc: usize, rstart: usize, cstart: usize, rgap: usize, cgap: usize, rs: usize, cs: usize, func: &dyn Fn(&Self, usize, usize) -> Self, ) -> Shapes
pub fn invert_colour(&self) -> Self
pub fn blank(&self) -> Self
pub fn copy(&self, other: &Self) -> Self
pub fn copy_not_colour(&self, other: &Self, nc: Colour) -> Self
pub fn get_joined(&self) -> Shapes
pub fn fill_centre_mut(&mut self, colour: Colour)
pub fn mid_pixel(&self) -> (usize, usize)
pub fn swap_colours(&mut self, cm: &BTreeMap<Colour, Colour>)
pub fn adjacent_to_pixel(&self, grid: &Grid) -> Vec<Direction>
Trait Implementations§
Source§impl Ord for Shape
impl Ord for Shape
Source§impl PartialOrd for Shape
impl PartialOrd for Shape
impl Eq for Shape
Auto Trait Implementations§
impl Freeze for Shape
impl RefUnwindSafe for Shape
impl Send for Shape
impl Sync for Shape
impl Unpin for Shape
impl UnwindSafe for Shape
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more