pub struct Selection(/* private fields */);Expand description
A pixel selection within a view.
Implementations§
Methods from Deref<Target = Rect<i32>>§
pub fn scale(&self, x: T, y: T) -> Rect<T>
Sourcepub fn with_origin(&self, x: T, y: T) -> Rect<T>
pub fn with_origin(&self, x: T, y: T) -> Rect<T>
Return the rectangle with a different origin.
§Examples
use rgx::rect::Rect;
let r = Rect::new(1, 1, 4, 4);
assert_eq!(r.with_origin(0, 0), Rect::new(0, 0, 3, 3));Sourcepub fn with_size(&self, w: T, h: T) -> Rect<T>
pub fn with_size(&self, w: T, h: T) -> Rect<T>
Return the rectangle with a different size.
§Examples
use rgx::rect::Rect;
let r = Rect::new(1, 1, 4, 4);
assert_eq!(r.with_size(9, 9), Rect::new(1, 1, 10, 10));Sourcepub fn expand(&self, x1: T, y1: T, x2: T, y2: T) -> Rect<T>
pub fn expand(&self, x1: T, y1: T, x2: T, y2: T) -> Rect<T>
Return an expanded rectangle by a constant amount.
§Examples
use rgx::rect::Rect;
let r = Rect::new(0, 0, 3, 3);
assert_eq!(r.expand(1, 1, 1, 1), Rect::new(-1, -1, 4, 4));
let r = Rect::new(3, 3, 0, 0);
assert_eq!(r.expand(1, 1, 1, 1), Rect::new(4, 4, -1, -1));
let r = Rect::new(-1, 1, 1, -1);
assert_eq!(r.expand(4, 4, 4, 4), Rect::new(-5, 5, 5, -5));pub fn is_empty(&self) -> boolwhere
T: PartialEq,
pub fn is_zero(&self) -> boolwhere
T: Zero,
Sourcepub fn width(&self) -> T
pub fn width(&self) -> T
Return the width of the rectangle.
§Examples
use rgx::rect::Rect;
let r = Rect::new(0, 0, 3, 3);
assert_eq!(r.width(), 3);Sourcepub fn height(&self) -> T
pub fn height(&self) -> T
Return the height of the rectangle.
§Examples
use rgx::rect::Rect;
let r = Rect::origin(-6, -6);
assert_eq!(r.height(), 6);Sourcepub fn min(&self) -> Point2<T>where
T: PartialOrd + Copy,
pub fn min(&self) -> Point2<T>where
T: PartialOrd + Copy,
Return the minimum point of a rectangle.
§Examples
use rgx::rect::Rect;
use rgx::math::Point2;
let r = Rect::new(0, 0, 1, -1);
assert_eq!(r.min(), Point2::new(0, -1));Sourcepub fn max(&self) -> Point2<T>where
T: PartialOrd + Copy,
pub fn max(&self) -> Point2<T>where
T: PartialOrd + Copy,
Return the maximum point of a rectangle.
§Examples
use rgx::rect::Rect;
use rgx::math::Point2;
let r = Rect::origin(-1, 1);
assert_eq!(r.max(), Point2::new(0, 1));Sourcepub fn center(&self) -> Point2<T>
pub fn center(&self) -> Point2<T>
Return the center of the rectangle.
§Examples
use rgx::rect::Rect;
use rgx::math::Point2;
let r = Rect::origin(8, 8);
assert_eq!(r.center(), Point2::new(4, 4));
let r = Rect::new(0, 0, -8, -8);
assert_eq!(r.center(), Point2::new(-4, -4));pub fn radius(&self) -> T
Sourcepub fn contains(&self, p: Point2<T>) -> boolwhere
T: Copy + PartialOrd,
pub fn contains(&self, p: Point2<T>) -> boolwhere
T: Copy + PartialOrd,
Check whether the given point is contained in the rectangle.
use rgx::rect::Rect;
use rgx::math::Point2;
let r = Rect::origin(6, 6);
assert!(r.contains(Point2::new(0, 0)));
assert!(r.contains(Point2::new(3, 3)));
assert!(!r.contains(Point2::new(6, 6)));
let r = Rect::new(0, 0, -6, -6);
assert!(r.contains(Point2::new(-3, -3)));pub fn intersects(&self, other: Rect<T>) -> boolwhere
T: PartialOrd,
Sourcepub fn abs(&self) -> Rect<T>
pub fn abs(&self) -> Rect<T>
Return the absolute rectangle.
§Examples
use rgx::rect::Rect;
let r = Rect::new(3, 3, 1, 1).abs();
assert_eq!(r, Rect::new(1, 1, 3, 3));
let r = Rect::new(-1, -1, 1, 1).abs();
assert_eq!(r, Rect::new(-1, -1, 1, 1));Sourcepub fn intersection(&self, other: Rect<T>) -> Rect<T>
pub fn intersection(&self, other: Rect<T>) -> Rect<T>
Return the intersection between two rectangles.
§Examples
use rgx::rect::Rect;
let other = Rect::new(0, 0, 3, 3);
let r = Rect::new(1, 1, 6, 6);
assert_eq!(r.intersection(other), Rect::new(1, 1, 3, 3));
let r = Rect::new(1, 1, 2, 2);
assert_eq!(r.intersection(other), Rect::new(1, 1, 2, 2));
let r = Rect::new(-1, -1, 3, 3);
assert_eq!(r.intersection(other), Rect::new(0, 0, 3, 3));
let r = Rect::new(-1, -1, 4, 4);
assert_eq!(r.intersection(other), other);
let r = Rect::new(4, 4, 5, 5);
assert!(r.intersection(other).is_empty());Trait Implementations§
impl Copy for Selection
impl Eq for Selection
impl StructuralPartialEq for Selection
Auto Trait Implementations§
impl Freeze for Selection
impl RefUnwindSafe for Selection
impl Send for Selection
impl Sync for Selection
impl Unpin for Selection
impl UnwindSafe for Selection
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