[][src]Struct rx::session::Selection

pub struct 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]

pub fn with_origin(&self, x: T, y: T) -> Rect<T> where
    T: Add<T, Output = T> + Sub<T, Output = T> + Copy
[src]

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]

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]

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]

Return the rectangle flipped in the Y axis.

pub fn flip_x(&self) -> Rect<T> where
    T: Copy
[src]

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]

Return the area of a rectangle.

pub fn is_empty(&self) -> bool where
    T: PartialEq<T>, 
[src]

pub fn is_zero(&self) -> bool where
    T: Zero
[src]

pub fn width(&self) -> T where
    T: Copy + PartialOrd<T> + Sub<T, Output = T>, 
[src]

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]

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]

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]

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]

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]

pub fn contains(&self, p: Point2<T>) -> bool where
    T: Copy + PartialOrd<T>, 
[src]

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]

pub fn abs(&self) -> Rect<T> where
    T: Ord + Copy
[src]

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]

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]

type Target = Rect<i32>

The resulting type after dereferencing.

impl Eq for Selection[src]

impl PartialEq<Selection> for Selection[src]

impl StructuralEq for Selection[src]

impl StructuralPartialEq for Selection[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.