Struct svgbob::buffer::Cell

source ·
pub struct Cell {
    pub x: i32,
    pub y: i32,
}
Expand description
     0 1 2 3 4           B C D
    0┌─┬─┬─┬─┐        A┌─┬─┬─┬─┐E
    1├─┼─┼─┼─┤         │ │ │ │ │
    2├─┼─┼─┼─┤        F├─G─H─I─┤J
    3├─┼─┼─┼─┤         │ │ │ │ │
    4├─┼─┼─┼─┤        K├─L─M─N─┤O
    5├─┼─┼─┼─┤         │ │ │ │ │
    6├─┼─┼─┼─┤        P├─Q─R─S─┤T
    7├─┼─┼─┼─┤         │ │ │ │ │
    8└─┴─┴─┴─┘        U└─┴─┴─┴─┘Y
```                      V W X
A single element in the terminal that
can fit 1 character.
Describe the exact location of a point/subcell in a grid.

Fields§

§x: i32§y: i32

Implementations§

source§

impl Cell

source

pub fn a(&self) -> Point

The point at specific cell grid of this cell

source

pub fn b(&self) -> Point

source

pub fn c(&self) -> Point

source

pub fn d(&self) -> Point

source

pub fn e(&self) -> Point

source

pub fn f(&self) -> Point

source

pub fn g(&self) -> Point

source

pub fn h(&self) -> Point

source

pub fn i(&self) -> Point

source

pub fn j(&self) -> Point

source

pub fn k(&self) -> Point

source

pub fn l(&self) -> Point

source

pub fn m(&self) -> Point

source

pub fn n(&self) -> Point

source

pub fn o(&self) -> Point

source

pub fn p(&self) -> Point

source

pub fn q(&self) -> Point

source

pub fn r(&self) -> Point

source

pub fn s(&self) -> Point

source

pub fn t(&self) -> Point

source

pub fn u(&self) -> Point

source

pub fn v(&self) -> Point

source

pub fn w(&self) -> Point

source

pub fn x(&self) -> Point

source

pub fn y(&self) -> Point

source

pub fn new(x: i32, y: i32) -> Self

source

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

returns true if the other cell is at: top_left, top, top_right, left, right, bottom_left, bottom, bottom_right of self

source

pub fn snap_point(point: Point) -> (Self, Point)

Derive which cell this points falls into and snap the point closes to any intersection in the cell grid. FIXME: need to find a way to snap a group of point that lies in boundaries to snap together to a common cell.

source

pub fn snap_group(points: &[Point]) -> Self

source

pub fn top_left_most(&self) -> Point

The point at the top right of this cell

source

pub fn bottom_right_most(&self) -> Point

source

pub fn localize_point(&self, point: Point) -> Point

turn point into relative distance from the top-left of this cell by simply deducting the point p with this cell’s top_left_most point

source

pub fn localize_cell(&self, cell: Cell) -> Cell

source

pub fn width() -> f32

source

pub fn height() -> f32

source

pub fn unit(l: i32) -> f32

source

pub fn is_intersected(&self, start: Point, end: Point) -> bool

test whether this cell is intersected with the line segment with point start and end

source

pub fn is_bounded(&self, bound1: Cell, bound2: Cell) -> bool

check if this cell is bounded by the lower bound and upper bound

source

pub fn snap(p: Point) -> Point

snap point to a closest intersection of this cellgrid

source

pub fn clip_line_snap(&self, start: Point, end: Point) -> Option<(Point, Point)>

source

pub fn clip_line_localize( &self, start: Point, end: Point ) -> Option<(Point, Point)>

clip line then localize the points and snap to the nearest cell grid intersection

source

pub fn top_left(&self) -> Self

The cell at the top left of this cell

source

pub fn top(&self) -> Self

source

pub fn top_right(&self) -> Self

source

pub fn left(&self) -> Self

The cell at the left of this cell

source

pub fn right(&self) -> Self

source

pub fn bottom_left(&self) -> Self

source

pub fn bottom(&self) -> Self

source

pub fn bottom_right(&self) -> Self

source

pub fn rearrange_bound(bound1: Cell, bound2: Cell) -> (Cell, Cell)

rearrange the bound of 2 cells

Trait Implementations§

source§

impl Add<Cell> for Cell

§

type Output = Cell

The resulting type after applying the + operator.
source§

fn add(self, other: Self) -> Self::Output

Performs the + operation. Read more
source§

impl Clone for Cell

source§

fn clone(&self) -> Cell

Returns a copy 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 Cell

source§

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

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

impl Display for Cell

source§

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

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

impl Hash for Cell

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Cell

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Cell> for Cell

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Cell> for Cell

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Sub<Cell> for Cell

§

type Output = Cell

The resulting type after applying the - operator.
source§

fn sub(self, other: Self) -> Self::Output

Performs the - operation. Read more
source§

impl Copy for Cell

source§

impl Eq for Cell

source§

impl StructuralEq for Cell

source§

impl StructuralPartialEq for Cell

Auto Trait Implementations§

§

impl RefUnwindSafe for Cell

§

impl Send for Cell

§

impl Sync for Cell

§

impl Unpin for Cell

§

impl UnwindSafe for Cell

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<Q, K> Comparable<K> for Qwhere Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T, Global>) -> Arc<dyn Any + Send + Sync, Global>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<T> Scalar for Twhere T: 'static + Clone + PartialEq<T> + Debug,