[−][src]Struct rx::session::Selection
A pixel selection within a view.
Methods
impl Selection
[src]
pub fn new(x1: i32, y1: i32, x2: i32, y2: i32) -> Self
[src]
Create a new selection from a rectangle.
pub fn from(r: Rect<i32>) -> Self
[src]
Create a new selection from a rectangle.
pub fn bounds(&self) -> Rect<i32>
[src]
Return the selection bounds as a non-empty rectangle. This function will never return an empty rectangle.
pub fn abs(&self) -> Selection
[src]
Return the absolute selection.
pub fn translate(&mut self, x: i32, y: i32)
[src]
Translate the selection rectangle.
pub fn resize(&mut self, x: i32, y: i32)
[src]
Resize the selection by a certain amount.
Methods from Deref<Target = Rect<i32>>
pub fn scale(&self, x: T, y: T) -> Rect<T> where
T: Mul<T, Output = T> + Copy,
[src]
T: Mul<T, Output = T> + Copy,
pub fn with_origin(&self, x: T, y: T) -> Rect<T> where
T: Add<T, Output = T> + Sub<T, Output = T> + Copy,
[src]
T: Add<T, Output = T> + Sub<T, Output = T> + Copy,
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));
pub fn with_size(&self, w: T, h: T) -> Rect<T> where
T: Add<T, Output = T> + Sub<T, Output = T> + Copy,
[src]
T: Add<T, Output = T> + Sub<T, Output = T> + Copy,
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));
pub fn expand(&self, x1: T, y1: T, x2: T, y2: T) -> Rect<T> where
T: Add<T, Output = T> + Sub<T, Output = T> + PartialOrd<T> + Copy,
[src]
T: Add<T, Output = T> + Sub<T, Output = T> + PartialOrd<T> + Copy,
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 flip_y(&self) -> Rect<T> where
T: Copy,
[src]
T: Copy,
Return the rectangle flipped in the Y axis.
pub fn flip_x(&self) -> Rect<T> where
T: Copy,
[src]
T: Copy,
Return the rectangle flipped in the X axis.
pub fn area(&self) -> T where
T: Copy + Sub<T, Output = T> + PartialOrd<T> + Mul<T, Output = T>,
[src]
T: Copy + Sub<T, Output = T> + PartialOrd<T> + Mul<T, Output = T>,
Return the area of a rectangle.
pub fn is_empty(&self) -> bool where
T: PartialEq<T>,
[src]
T: PartialEq<T>,
pub fn is_zero(&self) -> bool where
T: Zero,
[src]
T: Zero,
pub fn width(&self) -> T where
T: Copy + PartialOrd<T> + Sub<T, Output = T>,
[src]
T: Copy + PartialOrd<T> + Sub<T, Output = 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);
pub fn height(&self) -> T where
T: Copy + PartialOrd<T> + Sub<T, Output = T>,
[src]
T: Copy + PartialOrd<T> + Sub<T, Output = T>,
Return the height of the rectangle.
Examples
use rgx::rect::Rect; let r = Rect::origin(-6, -6); assert_eq!(r.height(), 6);
pub fn min(&self) -> Point2<T> where
T: PartialOrd<T> + Copy,
[src]
T: PartialOrd<T> + 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));
pub fn max(&self) -> Point2<T> where
T: PartialOrd<T> + Copy,
[src]
T: PartialOrd<T> + 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));
pub fn center(&self) -> Point2<T> where
T: Div<T, Output = T> + Copy + Ord + From<i16> + PartialOrd<T> + Zero + Neg<Output = T> + Sub<T, Output = T>,
[src]
T: Div<T, Output = T> + Copy + Ord + From<i16> + PartialOrd<T> + Zero + Neg<Output = T> + Sub<T, Output = 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 where
T: Div<T, Output = T> + Copy + From<i16> + PartialOrd<T> + Zero + Neg<Output = T> + Sub<T, Output = T>,
[src]
T: Div<T, Output = T> + Copy + From<i16> + PartialOrd<T> + Zero + Neg<Output = T> + Sub<T, Output = T>,
pub fn contains(&self, p: Point2<T>) -> bool where
T: Copy + PartialOrd<T>,
[src]
T: Copy + PartialOrd<T>,
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>) -> bool where
T: PartialOrd<T>,
[src]
T: PartialOrd<T>,
pub fn abs(&self) -> Rect<T> where
T: Ord + Copy,
[src]
T: Ord + Copy,
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));
pub fn intersection(&self, other: Rect<T>) -> Rect<T> where
T: Ord + Copy,
[src]
T: Ord + Copy,
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 Clone for Selection
[src]
impl Copy for Selection
[src]
impl Debug for Selection
[src]
impl Deref for Selection
[src]
impl Eq for Selection
[src]
impl PartialEq<Selection> for Selection
[src]
impl StructuralEq for Selection
[src]
impl StructuralPartialEq for Selection
[src]
Auto Trait Implementations
impl RefUnwindSafe for Selection
impl Send for Selection
impl Sync for Selection
impl Unpin for Selection
impl UnwindSafe for Selection
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> SetParameter for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,