Shapes

Struct Shapes 

Source
pub struct Shapes {
    pub nrows: usize,
    pub ncols: usize,
    pub colour: Colour,
    pub shapes: Vec<Shape>,
}

Fields§

§nrows: usize§ncols: usize§colour: Colour§shapes: Vec<Shape>

Implementations§

Source§

impl Shapes

Source

pub fn new() -> Self

Source

pub const fn trivial() -> Self

Source

pub fn new_sized(nrows: usize, ncols: usize) -> Self

Source

pub fn new_given(nrows: usize, ncols: usize, shapes: &Vec<Shape>) -> Self

Source

pub fn new_from_shape(shape: &Shape) -> Self

Source

pub fn new_shapes(shapes: &[Shape]) -> Self

Source

pub fn new_shapes_sized(nrows: usize, ncols: usize, shapes: &[Shape]) -> Self

Source

pub fn clone_base(&self) -> Self

Source

pub fn merge_mut(&mut self, other: &Self)

Source

pub fn join_shapes_same_colour(&self) -> Self

Source

pub fn find_straight_pairs(&self) -> BTreeMap<Shape, Shape>

Source

pub fn group_containers(&self) -> BTreeMap<Shape, Vec<Shape>>

Source

pub fn coords_to_shape(&self) -> BTreeMap<(usize, usize), Shape>

Source

pub fn centre_of(&self) -> BTreeMap<(usize, usize), Shape>

Source

pub fn border_gravity(&self) -> BTreeMap<Colour, Direction>

Source

pub fn in_range(&self, rc: usize, vertical: bool) -> bool

Source

pub fn full_shapes(&self) -> Vec<Shape>

Source

pub fn full_shapes_sq(&self) -> Vec<Shape>

Source

pub fn all_shapes(&self) -> Vec<Shape>

Source

pub fn contains_shape(&self, shape: &Shape) -> bool

Source

pub fn contains_origin(shapes: &Vec<&Shape>, r: usize, c: usize) -> bool

Source

pub fn all_shapes_sq(&self) -> Vec<Shape>

Source

pub fn shape_permutations(&self) -> Self

Source

pub fn find_shape_colours(&self) -> Vec<Colour>

Source

pub fn get_pixels(&self) -> Shapes

Source

pub fn is_line(&self) -> bool

Source

pub fn has_band(&self) -> (Direction, usize)

Source

pub fn is_square(&self) -> bool

Source

pub fn is_square_same(&self) -> bool

Source

pub fn anomalous_colour(&self) -> Option<Colour>

Source

pub fn embellish(&self, colour: Colour) -> Shapes

Source

pub fn colours(&self) -> Vec<Colour>

Source

pub fn find_repeats(&self) -> (usize, usize)

Source

pub fn find_gaps(&self) -> (usize, usize)

Source

pub fn anomalous_size(&self) -> Option<usize>

Source

pub fn colour_groups_to_shapes(&self, bg: Colour) -> Shapes

Source

pub fn colour_cnt(&self) -> BTreeMap<Colour, usize>

Source

pub fn cell_colour_cnt(&self) -> BTreeMap<Colour, usize>

Source

pub fn size_cnt(&self) -> BTreeMap<usize, usize>

Source

pub fn nearest_shape(&self, r: usize, c: usize) -> Shape

Source

pub fn full_extent(&self) -> Shape

Source

pub fn all_corners(&self) -> Vec<(usize, usize)>

Source

pub fn vec_corners(shapes: &Vec<Shape>) -> (usize, usize, usize, usize)

Source

pub fn corners(&self) -> (usize, usize, usize, usize)

Source

pub fn origins(shapes: &Vec<&Shape>) -> Vec<(usize, usize)>

Source

pub fn to_shape(&self) -> Shape

Source

pub fn border_only(&self) -> Shape

Source

pub fn all(&self) -> Vec<Shape>

Source

pub fn smallest(&self) -> Shape

Source

pub fn largest(&self) -> Shape

Source

pub fn largest_solid(&self) -> Shape

Source

pub fn largest_solid_colour(&self, colour: Colour) -> Shape

Source

pub fn hollow_cnt_colour_map(&self) -> BTreeMap<usize, Colour>

Source

pub fn hollow_cnt_max(&self) -> Shape

Source

pub fn hollow_cnt_min(&self) -> Shape

Source

pub fn hollow_cnt_map(&self) -> BTreeMap<usize, Vec<Shape>>

Source

pub fn hollow_cnt_unique(&self) -> Shape

Source

pub fn first(&self) -> Shape

Source

pub fn last(&self) -> Shape

Source

pub fn shape_colour_cnt_map(&self) -> BTreeMap<Colour, Vec<Shape>>

Source

pub fn pixels_in_shapes(&self, shape: &Shape) -> Vec<Shape>

Source

pub fn overlay_shapes_same_colour(&self) -> bool

Source

pub fn overlay_shapes_diff_colour(&self) -> bool

Source

pub fn consolidate_shapes(&self) -> Self

Source

pub fn find_pixels(&self) -> Self

Source

pub fn find_shapes(&self) -> Self

Source

pub fn size(&self) -> usize

Source

pub fn width(&self) -> usize

Source

pub fn height(&self) -> usize

Source

pub fn find_by_colour(&self, colour: Colour) -> Shape

Source

pub fn find_min(&self) -> Shape

Source

pub fn find_max(&self) -> Shape

Source

pub fn find_sub_min(&self) -> Shape

Source

pub fn find_sub_max(&self) -> Shape

Source

pub fn find_pixels_min(&self) -> Shape

Source

pub fn find_pixels_max(&self) -> Shape

Source

pub fn find_max_colour_count(&self) -> Shape

Source

pub fn find_sub_largest_count(&self) -> Shape

Source

pub fn position_pixels(&self) -> Option<(Self, Self)>

Source

pub fn contained_pairs(&self) -> BTreeMap<Shape, Shape>

Source

pub fn pair_shapes( &self, other: &Shapes, match_colour: bool, ) -> Vec<(Shape, Shape, bool)>

Source

pub fn toddle_colours(&self) -> Self

Source

pub fn min_size(&self, sz: usize) -> (usize, usize)

Source

pub fn split_size(&self, sz: usize) -> Self

Source

pub fn majority_cell(&self) -> Shape

Source

pub fn ignore_pixels(&self) -> Self

Source

pub fn de_subshape(&self) -> Shapes

Source

pub fn diff(&self, other: &Self) -> Option<Vec<Option<Shape>>>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn add(&mut self, shape: &Shape)

Source

pub fn noise_colour(&self) -> Colour

Source

pub fn important_shapes(&self) -> Vec<Shape>

Source

pub fn remove(&mut self, shape: &Shape)

Source

pub fn hollow_shapes(&self) -> Shapes

Source

pub fn merge_replace_shapes(&self, other: &Self) -> Self

Source

pub fn show_summary(&self)

Source

pub fn show(&self)

Source

pub fn show_full(&self)

Source

pub fn trim_grid(&self) -> Self

Source

pub fn trim_to_grid(&self) -> Grid

Source

pub fn trim_to_grid_transparent(&self) -> Grid

Source

pub fn to_grid(&self) -> Grid

Source

pub fn to_grid_transparent(&self) -> Grid

Source

pub fn to_grid_colour(&self, colour: Colour) -> Grid

Source

pub fn to_grid_colour_transparent(&self, colour: Colour) -> Grid

Source

pub fn to_grid_impl(&self, colour: Colour, transparent: bool) -> Grid

Source

pub fn to_json(&self) -> String

Source

pub fn shape_counts(&self) -> BTreeMap<u32, usize>

Source

pub fn holes_sizes(&self) -> Vec<(Shape, usize)>

Source

pub fn have_common_pixel(&self) -> (Colour, Vec<Self>)

Source

pub fn striped_r(&self) -> Colour

Source

pub fn striped_c(&self) -> Colour

Source

pub fn shrink(&self) -> Self

Source

pub fn fill_missing(&self, to: Colour) -> Self

Source

pub fn pixel_dir(&self, grid: &Grid) -> BTreeMap<Shape, Vec<Direction>>

Source

pub fn biggest_shape(&self) -> Shape

Source

pub fn has_mirror_r(&self) -> Shape

Source

pub fn has_mirror_c(&self) -> Shape

Source

pub fn cell_colour_cnts(&self, colour: Colour) -> Shape

Source

pub fn get_by_colour(&self, colour: Colour) -> Vec<Shape>

Trait Implementations§

Source§

impl Clone for Shapes

Source§

fn clone(&self) -> Shapes

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Shapes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Shapes

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Shapes

Source§

fn eq(&self, other: &Shapes) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Shapes

Auto Trait Implementations§

§

impl Freeze for Shapes

§

impl RefUnwindSafe for Shapes

§

impl Send for Shapes

§

impl Sync for Shapes

§

impl Unpin for Shapes

§

impl UnwindSafe for Shapes

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.