pub struct Grid {
pub colour: Colour,
pub cells: Matrix<Cell>,
}Fields§
§colour: Colour§cells: Matrix<Cell>Implementations§
Source§impl Grid
impl Grid
pub fn new(rows: usize, cols: usize, colour: Colour) -> Self
pub fn trivial() -> Self
pub fn dummy() -> Self
pub fn is_trivial(&self) -> bool
pub fn is_dummy(&self) -> bool
pub fn new_from_matrix(cells: &Matrix<Cell>) -> Self
pub fn rip(&self, colour: Colour) -> Self
pub fn duplicate(grid: &[Vec<usize>]) -> Self
pub fn is_empty(&self) -> bool
pub fn to_origin(&self) -> Self
pub fn to_origin_mut(&mut self)
pub fn find_colour_pixel_coords(&self, colour: Colour) -> (usize, usize)
pub fn find_different_pixel_coords(&self) -> (usize, usize)
pub fn find_colour(&self, colour: Colour) -> Vec<Cell>
pub fn in_to_squared_out(&self) -> Self
pub fn find_all_colours(&self) -> BTreeMap<Colour, usize>
pub fn find_min_colour(&self) -> Colour
pub fn find_max_colour(&self) -> Colour
pub fn stretch_down(&self) -> Self
pub fn is_diag_origin(&self) -> bool
pub fn is_diag_not_origin(&self) -> bool
pub fn gravity_down(&self) -> Self
pub fn gravity_down_colour(&self, colour: Colour) -> Self
pub fn gravity_up(&self) -> Self
pub fn gravity_right(&self) -> Self
pub fn gravity_left(&self) -> Self
pub fn move_down(&self) -> Self
pub fn move_up(&self) -> Self
pub fn move_right(&self) -> Self
pub fn move_left(&self) -> Self
pub fn trim(&self, r: usize, c: usize) -> Self
pub fn free_border(&self, dir: Direction) -> bool
pub fn negative_mut(&mut self, colour: Colour)
pub fn negative_dir_all_mut(&mut self, colour: Colour)
pub fn negative_dir_mut(&mut self, colour: Colour, exclude: Vec<Direction>)
pub fn background_border_mut(&mut self)
pub fn row_dividers_mut(&mut self, rs: usize)
pub fn col_dividers_mut(&mut self, cs: usize)
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 copy_to_position(&self, grid: &Self, r: usize, c: usize) -> Self
pub fn copy_to_position_mut(&mut self, grid: &Self, rp: usize, cp: usize)
pub fn copy_shape_to_grid_mut(&mut self, shape: &Shape)
pub fn copy_shape_to_grid_position_mut( &mut self, shape: &Shape, row: usize, col: usize, )
pub fn connect_dots_pairs(&mut self)
pub fn connect_dots(&mut self)
pub fn connect_dots_colour(&mut self, colour: Colour)
pub fn connect_dots_colour_pairs(&mut self, colour: Colour)
pub fn connect_dots_dir(&mut self, dir: Direction, col: Colour)
pub fn draw_lines_from_shapes( &mut self, shapes: &[Shape], overwrite: bool, hv: bool, )
pub fn draw_lines(&mut self, shapes: &[&Shape], overwrite: bool, hv: bool)
pub fn draw_mut(&mut self, dir: Direction, r: usize, c: usize, colour: Colour)
pub fn draw_bg_mut( &mut self, dir: Direction, r: usize, c: usize, colour: Colour, bg: Colour, )
pub fn draw_mc_mut( &mut self, dir: Direction, r: usize, c: usize, colour: Colour, )
pub fn draw_term_mut( &mut self, dir: Direction, r: usize, c: usize, colour: Colour, )
pub fn draw_bg_mc_mut( &mut self, dir: Direction, r: usize, c: usize, colour: Colour, bg: Colour, )
pub fn draw_bg_term_mut( &mut self, dir: Direction, r: usize, c: usize, colour: Colour, bg: Colour, )
pub fn draw_bg_mc_term_mut( &mut self, dir: Direction, r: usize, c: usize, colour: Colour, bg: Colour, mc: bool, term: bool, )
pub fn draw_bg_mc_term_other_mut( &mut self, dir: Direction, r: usize, c: usize, colour: Colour, bg: Colour, mc: bool, term: bool, other_colour: Colour, )
pub fn skip_to(&self, dir: Direction, r: usize, c: usize) -> (usize, usize)
pub fn skip_to_bg( &self, dir: Direction, r: usize, c: usize, bg: Colour, ) -> (usize, usize)
pub fn calc_direction(r1: usize, c1: usize, r2: usize, c2: usize) -> Direction
pub fn shape_in_line(&self, shape: &Shape) -> Colour
pub fn trim_excess_mut(&mut self)
pub fn draw_line_row( &mut self, s1: &Shape, s2: &Shape, colour: Colour, overwrite: bool, fill: bool, )
pub fn draw_line_row_coords( &mut self, r1: usize, c1: usize, r2: usize, c2: usize, colour: Colour, overwrite: bool, fill: bool, thick: usize, )
pub fn draw_line_col( &mut self, s1: &Shape, s2: &Shape, colour: Colour, overwrite: bool, fill: bool, )
pub fn draw_line_col_coords( &mut self, r1: usize, c1: usize, r2: usize, c2: usize, colour: Colour, overwrite: bool, fill: bool, thick: usize, )
pub fn extend_border(&self) -> Self
pub fn extend_right(&self) -> Self
pub fn extend_left(&self) -> Self
pub fn extend_down(&self) -> Self
pub fn extend_up(&self) -> Self
pub fn extend_right_by(&self, amount: usize) -> Self
pub fn extend_left_by(&self, amount: usize) -> Self
pub fn extend_down_by(&self, amount: usize) -> Self
pub fn extend_up_by(&self, amount: usize) -> Self
pub fn dup_func(&self, lr: bool, func: &dyn Fn(&Self) -> Self) -> Self
pub fn dup_right(&self) -> Self
pub fn dup_left(&self) -> Self
pub fn dup_down(&self) -> Self
pub fn dup_up(&self) -> Self
pub fn dup_right_func(&self, func: &dyn Fn(&Self) -> Self) -> Self
pub fn dup_left_func(&self, func: &dyn Fn(&Self) -> Self) -> Self
pub fn dup_down_func(&self, func: &dyn Fn(&Self) -> Self) -> Self
pub fn dup_up_func(&self, func: &dyn Fn(&Self) -> Self) -> Self
pub fn mirror_dir_func(&self, lr: bool, func: &dyn Fn(&Self) -> Self) -> Self
pub fn mirror_dir(&self, lr: bool) -> Self
pub fn mirror_right(&self) -> Self
pub fn mirror_left(&self) -> Self
pub fn mirror_down(&self) -> Self
pub fn mirror_up(&self) -> Self
pub fn mirror_right_func(&self, func: &dyn Fn(&Self) -> Self) -> Self
pub fn mirror_left_func(&self, func: &dyn Fn(&Self) -> Self) -> Self
pub fn mirror_down_func(&self, func: &dyn Fn(&Self) -> Self) -> Self
pub fn mirror_up_func(&self, func: &dyn Fn(&Self) -> Self) -> Self
pub fn pixels(&self) -> usize
pub fn transform(&self, trans: Transformation) -> Self
pub fn inverse_transform(&self, trans: Transformation) -> Self
pub fn inverse_colour(&self) -> Self
pub fn colour(&self) -> Colour
pub fn size(&self) -> usize
pub fn same_size(&self, other: &Self) -> bool
pub fn same_shape(&self, other: &Self) -> bool
pub fn dimensions(&self) -> (usize, usize)
pub fn add_border(&self, n: usize) -> Self
pub fn add_border_colour(&self, n: usize, colour: Colour) -> Self
pub fn remove_border(&self, n: usize) -> Self
pub fn max_dim(&self) -> usize
pub fn derive_missing_rule(&self, other: &Self) -> Self
pub fn apply_missing_rule(&self, other: &Self) -> Self
pub fn copy_centre(&mut self, cr: usize, cc: usize, other: &Self)
pub fn fill_border(&mut self)
pub fn has_colour( &self, tlr: usize, tlc: usize, rlen: usize, clen: usize, colour: Colour, ) -> bool
pub fn find_row_seq( &self, sr: usize, sc: usize, seq: &[Colour], width: usize, ) -> (usize, usize)
pub fn find_col_seq( &self, sr: usize, sc: usize, seq: &[Colour], length: usize, ) -> (usize, usize)
pub fn colour_every_nxn_for_m( colour: Colour, side: usize, n: usize, m: usize, ) -> Self
pub fn colour_dimensions(&self, colour: Colour) -> (usize, usize)
pub fn bigger(&self, other: &Self) -> bool
pub fn smaller(&self, other: &Self) -> bool
pub fn cell_count(&self) -> usize
pub fn cell_count_colour(&self, colour: Colour) -> usize
pub fn flood_fill( &self, x: usize, y: usize, ignore_colour: Colour, new_colour: Colour, ) -> Self
pub fn flood_fill_bg( &self, r: usize, c: usize, ignore_colour: Colour, bg: Colour, new_colour: Colour, ) -> Self
pub fn flood_fill_mut( &mut self, r: usize, c: usize, ignore_colour: Colour, new_colour: Colour, )
pub fn flood_fill_border_mut( &mut self, ignore_colour: Colour, new_colour: Colour, )
pub fn flood_fill_bg_mut( &mut self, r: usize, c: usize, ignore_colour: Colour, bg: Colour, new_colour: Colour, )
pub fn flood_fill_from_seeds( &self, ignore_colour: Colour, new_colour: Colour, ) -> Self
pub fn subgrid(&self, tlr: usize, sr: usize, tlc: usize, sc: usize) -> Self
pub fn cell_colours(&self) -> Vec<Colour>
pub fn cell_colour_cnt_map(&self) -> BTreeMap<Colour, usize>
pub fn cell_colour_posn_map(&self) -> BTreeMap<Colour, Vec<(usize, usize)>>
pub fn majority_colour(&self) -> Colour
pub fn minority_colour(&self) -> Colour
pub fn get_diff_colour(&self, other: &Self) -> Colour
pub fn cell_colour_cnt_map_diff(&self) -> BTreeMap<Colour, usize>
pub fn even_rows(&self) -> bool
pub fn even_columns(&self) -> bool
pub fn border_top(&self) -> bool
pub fn border_bottom(&self) -> bool
pub fn border_left(&self) -> bool
pub fn border_right(&self) -> bool
pub fn has_border(&self) -> bool
pub fn mirrored_rows(&self) -> Self
pub fn mirrored_cols(&self) -> Self
pub fn populate_skew_edge_lr(&self, shape: &Shape, colour: Colour) -> Shape
pub fn populate_skew_edge_tb(&self, shape: &Shape, colour: Colour) -> Shape
pub fn is_mirror_rows(&self) -> bool
pub fn is_mirror_cols(&self) -> bool
pub fn is_symmetric(&self) -> bool
pub fn is_mirror_offset_rows(&self, skew: i32) -> bool
pub fn is_mirror_offset_cols(&self, skew: i32) -> bool
pub fn is_panelled_rows(&self) -> bool
pub fn is_panelled_cols(&self) -> bool
pub fn transpose(&mut self)
pub fn transposed(&self) -> Self
pub fn inv_transposed(&self) -> Self
pub fn rotated_90(&self, times: usize) -> Self
pub fn rotated_270(&self, times: usize) -> Self
pub fn rotate_90(&self, times: usize) -> Self
pub fn rot_00(&self) -> Self
pub fn rot_90(&self) -> Self
pub fn rot_180(&self) -> Self
pub fn rot_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 colours(&self) -> BTreeMap<Colour, usize>
pub fn min_colour(&self) -> Colour
pub fn max_colour(&self) -> Colour
pub fn no_colours(&self) -> usize
pub fn single_colour(&self) -> Colour
pub fn do_circle(&self, colour: Colour, spiral: bool) -> Self
pub fn circle(&self, colour: Colour) -> Self
pub fn spiral(&self, colour: Colour) -> Self
pub fn show_matrix(m: &Matrix<Cell>, diff: bool, io: bool)
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 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 ray(&self, _direction: (i8, i8)) -> Shape
pub fn move(&self, _direction: (i8, i8)) -> Shape
pub fn template_shapes(&self, template: &Self) -> Shapes
pub fn fill_template(&self, filler: &Shape) -> Self
pub fn scale_up(&self, factor: usize) -> Self
pub fn scale_down(&self, factor: usize) -> Self
pub fn resize(&self, factor: usize) -> Self
pub fn resize_inc(&self, factor: usize) -> Self
pub fn find_patch(&self, patch: &Shape) -> (usize, usize)
pub fn find_axis_colour(&self, shape: &Shape) -> Colour
pub fn find_axis_colour_bg(&self, shape: &Shape, bg: Colour) -> Colour
pub fn colour_squares(&mut self, colour: Colour)
pub fn find_black_patches(&self) -> Shapes
pub fn find_black_patches_limit(&self, limit: usize) -> Shapes
pub fn find_colour_patches(&self, colour: Colour) -> Shapes
pub fn find_colour_patches_limit(&self, colour: Colour, limit: usize) -> Shapes
pub fn toddle_colour(&self, bg: Colour, fg: Colour) -> Self
pub fn to_shapes_base_bg(&self, bg: Colour) -> Shapes
pub fn mid_div_colour(&self) -> Colour
pub fn has_shapes_base_bg(&self) -> bool
pub fn copy_part_matrix( rs: usize, cs: usize, rows: usize, cols: usize, cells: &Matrix<Cell>, ) -> Matrix<Cell>
pub fn to_shapes_coloured(&self) -> Shapes
pub fn to_shapes(&self) -> Shapes
pub fn to_shapes_cons(&self) -> Shapes
pub fn to_shapes_coloured_bg(&self, bg: Colour) -> Shapes
pub fn to_shapes_bg(&self, bg: Colour) -> Shapes
pub fn to_shapes_bg_cons(&self, bg: Colour) -> Shapes
pub fn to_shapes_coloured_cbg(&self) -> Shapes
pub fn to_shapes_cbg(&self) -> Shapes
pub fn to_shapes_coloured_sq(&self) -> Shapes
pub fn to_shapes_sq(&self) -> Shapes
pub fn to_shapes_coloured_bg_sq(&self, bg: Colour) -> Shapes
pub fn to_shapes_bg_sq(&self, bg: Colour) -> Shapes
pub fn to_shapes_coloured_cbg_sq(&self) -> Shapes
pub fn to_shapes_cbg_sq(&self) -> Shapes
pub fn to_shapes_from_grid_gap(&self, gap: usize) -> Shapes
pub fn to_shapes_from_grid_border(&self, border: usize) -> Shapes
pub fn to_shapes_from_grid(&self) -> Shapes
pub fn to_shapes_from_grid_gap_border( &self, gap: usize, border: usize, ) -> Shapes
pub fn as_shape(&self) -> Shape
pub fn as_shape_position(&self, r: usize, c: usize) -> Shape
pub fn as_shapes(&self) -> Shapes
pub fn as_shapes_position(&self, r: usize, c: usize) -> Shapes
pub fn as_pixel_shapes(&self) -> Shapes
pub fn repeat_rows(&self, start: usize, colour: Colour) -> Vec<usize>
pub fn cover_rows(&self, start: usize, colour: Colour) -> Self
pub fn repeat_cols(&self, start: usize, colour: Colour) -> Vec<usize>
pub fn is_square(&self) -> bool
pub fn square(&self) -> usize
pub fn height(&self) -> usize
pub fn width(&self) -> usize
pub fn row_colour(&self, r: usize) -> Colour
pub fn row_colour_matrix(m: &Matrix<Cell>, r: usize, colour: Colour) -> Colour
pub fn find_pixel(&self, colour: Colour) -> (usize, usize)
pub fn invert_colour(&self) -> Self
pub fn invert_colour_new(&self, colour: Colour) -> Self
pub fn blank(&self) -> Self
pub fn col_colour(&self, c: usize) -> Colour
pub fn col_colour_matrix(m: &Matrix<Cell>, c: usize, colour: Colour) -> Colour
pub fn div9(&self) -> bool
pub fn is_3x3(&self) -> bool
pub fn is_full(&self) -> bool
pub fn has_marker(&self, shape: &Shape) -> bool
pub fn has_marker_colour(&self, s: &Shape, colour: Colour) -> bool
pub fn find_rectangles(&self) -> Shapes
pub fn has_gravity(&self, orientation: usize) -> bool
pub fn has_gravity_colour(&self, orientation: usize, colour: Colour) -> bool
pub fn has_gravity_down(&self) -> bool
pub fn has_gravity_up(&self) -> bool
pub fn has_gravity_left(&self) -> bool
pub fn has_gravity_right(&self) -> bool
pub fn equals(&self, other: &Self) -> Colour
pub fn bleach(&self) -> Self
pub fn equal_footprint(&self, other: &Self) -> bool
pub fn equal_shape(&self, other: &Self) -> bool
pub fn diff_only_diff(&self) -> Self
pub fn diff_only_and(&self, colour: Colour) -> Self
pub fn diff_only_or(&self, colour: Colour) -> Self
pub fn diff_only_xor(&self, colour: Colour) -> Self
pub fn diff_only_not(&self, colour: Colour) -> Self
pub fn diff_only_same(&self) -> Self
pub fn diff_black_same(&self, colour: Colour) -> Self
pub fn diff_other_same(&self, colour: Colour) -> Self
pub fn find_unique_colours(&self) -> Vec<Colour>
pub fn find_colour_row_order(&self) -> BTreeMap<usize, Colour>
pub fn diff_only_transparent(&self) -> 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 distance(&self, other: &Self) -> f64
pub fn centre_of(&self) -> (usize, usize)
pub fn centre_of_symmetry(&self) -> (usize, usize)
pub fn corners(&self) -> (usize, usize, usize, usize)
pub fn row_skew(&self) -> isize
pub fn col_skew(&self) -> isize
pub fn count_diff(&self) -> (usize, usize)
pub fn tile_mut(&mut self, tile: &Self)
pub fn roll_right(&self) -> Self
pub fn roll_left(&self) -> Self
pub fn roll_up(&self) -> Self
pub fn roll_down(&self) -> Self
pub fn to_json(&self) -> String
pub fn to_vec(&self) -> Vec<Vec<usize>>
pub fn corner_colours(&self) -> (Colour, Colour, Colour, Colour)
pub fn corner_idx(&self) -> (Self, Direction)
pub fn corner_body(&self, dir: Direction) -> Self
pub fn split_n_horizontal(&self, n: usize) -> Vec<Self>
pub fn split_n_vertical(&self, n: usize) -> Vec<Self>
pub fn split_4(&self) -> Vec<Self>
pub fn split_4_inline(&self, delimiter: bool) -> Shapes
pub fn full_row(&self, shape: &Shape) -> bool
pub fn full_col(&self, shape: &Shape) -> bool
pub fn full_dim_split(&self, shapes: &Shapes) -> (Colour, Shapes)
pub fn split_2(&self) -> Shapes
pub fn full(&self) -> bool
pub fn get_patch(&self, r: usize, c: usize, rows: usize, cols: usize) -> Shape
pub fn fill_patch_mut(&mut self, other: &Shape, or: usize, oc: usize)
pub fn fill_patch_coord_mut( &mut self, or: usize, oc: usize, rs: usize, cs: usize, colour: Colour, )
Sourcepub fn used_in_row(&self, r: usize, colour: Colour) -> bool
pub fn used_in_row(&self, r: usize, colour: Colour) -> bool
Code constraint solver predicates
pub fn used_in_col(&self, c: usize, colour: Colour) -> bool
pub fn solve( &mut self, pred: &dyn Fn(&Self, usize, usize, Colour) -> bool, ) -> bool
pub fn solve_depth( &mut self, pred: &dyn Fn(&Self, usize, usize, Colour) -> bool, depth: usize, ) -> bool
Trait Implementations§
Source§impl Ord for Grid
impl Ord for Grid
Source§impl PartialOrd for Grid
impl PartialOrd for Grid
impl Eq for Grid
impl StructuralPartialEq for Grid
Auto Trait Implementations§
impl Freeze for Grid
impl RefUnwindSafe for Grid
impl Send for Grid
impl Sync for Grid
impl Unpin for Grid
impl UnwindSafe for Grid
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