Enum svgbob::Fragment

source ·
pub enum Fragment {
    Line(Line),
    MarkerLine(MarkerLine),
    Circle(Circle),
    Arc(Arc),
    Polygon(Polygon),
    Rect(Rect),
    CellText(CellText),
    Text(Text),
}
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

Variants§

§

Line(Line)

§

MarkerLine(MarkerLine)

§

Circle(Circle)

§

Arc(Arc)

§

Polygon(Polygon)

§

Rect(Rect)

§

CellText(CellText)

§

Text(Text)

Implementations§

source§

impl Fragment

source

pub fn match_unicode(fragments: &[Fragment]) -> Option<char>

get the character that matches the shape present on this cell

source

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

source

pub fn is_intersecting(&self, bbox: &Aabb) -> bool

check if this fragment is intersecting with this bounding box Note: if intersection logic requires testing the solid shape inside the polygon use the ConvexPolygon of each shape instead of Polyline

source

pub fn is_inside(&self, bbox: &Aabb) -> bool

check if this fragment can be contain in the specified bounding box bbox

source

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

recompute the end points of this fragment offset by the cell location

source

pub fn scale(&self, scale: f32) -> Self

enlarge or shrink this fragment at scale

source

pub fn align(&self) -> Self

source

pub fn as_line(&self) -> Option<&Line>

source

pub fn as_rect(&self) -> Option<&Rect>

source

pub fn as_polygon(&self) -> Option<&Polygon>

source

pub fn as_arc(&self) -> Option<&Arc>

source

pub fn as_cell_text(&self) -> Option<&CellText>

source

pub fn as_text(&self) -> Option<&Text>

source

pub fn as_css_tag(&self) -> Vec<String>

if this is a cell text and is wrapped in braces then it is a css tag for the container

source

pub fn as_circle(&self) -> Option<&Circle>

source

pub fn is_circle(&self) -> bool

source

pub fn is_rect(&self) -> bool

source

pub fn is_text(&self) -> bool

source

pub fn is_cell_text(&self) -> bool

source

pub fn is_broken(&self) -> bool

Trait Implementations§

source§

impl Bounds for Fragment

source§

fn bounds(&self) -> (Point, Point)

source§

fn mins(&self) -> Point

source§

fn maxs(&self) -> Point

source§

impl Clone for Fragment

source§

fn clone(&self) -> Fragment

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 Fragment

source§

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

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

impl Display for Fragment

source§

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

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

impl From<Arc> for Fragment

source§

fn from(arc: Arc) -> Self

Converts to this type from the input type.
source§

impl From<CellText> for Fragment

source§

fn from(ct: CellText) -> Fragment

Converts to this type from the input type.
source§

impl From<Circle> for Fragment

source§

fn from(circle: Circle) -> Self

Converts to this type from the input type.
source§

impl<MSG> From<Fragment> for Node<MSG>

source§

fn from(fragment: Fragment) -> Node<MSG>

Converts to this type from the input type.
source§

impl From<Line> for Fragment

source§

fn from(line: Line) -> Self

Converts to this type from the input type.
source§

impl From<Rect> for Fragment

source§

fn from(rect: Rect) -> Self

Converts to this type from the input type.
source§

impl From<Text> for Fragment

source§

fn from(text: Text) -> Self

Converts to this type from the input type.
source§

impl Merge for Fragment

source§

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

merge this fragment to the other fragment if it is possible returns None if the fragment can not be merge

source§

fn merge_recursive(items: impl IntoIterator<Item = Self>) -> Vec<Self>where Self: Sized,

Merge all items until the size don’t change
source§

fn second_pass_merge(items: impl IntoIterator<Item = Self>) -> Vec<Self>where Self: Sized,

Iterate through each items in the group and merge that items that can be merged
source§

impl Ord for Fragment

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<Fragment> for Fragment

source§

fn eq(&self, other: &Self) -> 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<Fragment> for Fragment

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 Eq for Fragment

Auto Trait Implementations§

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,