pub fn new_size(&self, mouse: DVec2, transform: DAffine2, center: bool, constrain: bool) -> [DVec2; 2] {
		let mouse = transform.inverse().transform_point2(mouse);

		let mut min = self.bounds[0];
		let mut max = self.bounds[1];
		if self.top {
			min.y = mouse.y;
		} else if self.bottom {
			max.y = mouse.y;
		}
		if self.left {
			min.x = mouse.x
		} else if self.right {
			max.x = mouse.x;
		}

		let mut size = max - min;
		if constrain {
			size = match ((self.top || self.bottom), (self.left || self.right)) {
				(true, true) => DVec2::new(size.x, size.x / self.aspect_ratio).abs().max(DVec2::new(size.y * self.aspect_ratio, size.y).abs()) * size.signum(),
				(true, false) => DVec2::new(size.y * self.aspect_ratio, size.y),
				(false, true) => DVec2::new(size.x, size.x / self.aspect_ratio),
				_ => size,
			};
		}
		if center {
			if self.left || self.right {
				size.x *= 2.;
			}

			if self.bottom || self.top {
				size.y *= 2.;
			}
		}

		[min, size]
	}
/// Computes the new bounds with the given mouse move and modifier keys
Computes the new bounds with the given mouse move and modifier keys
Computes the new bounds with the given mouse move and modifier keys
pub fn new_size(&self, mouse: DVec2, transform: DAffine2, center: bool, constrain: bool) -> [DVec2; 2] {
		let mouse = transform.inverse().transform_point2(mouse);
		let mut min = self.bounds[0];
		let mut max = self.bounds[1];
		if self.top {
			min.y = mouse.y;
		} else if self.bottom {
			max.y = mouse.y;
		}
		if self.left {
			min.x = mouse.x
		} else if self.right {
			max.x = mouse.x;
		}
		let mut size = max - min;
		if constrain {
			size = match ((self.top || self.bottom), (self.left || self.right)) {
				(true, true) => DVec2::new(size.x, size.x / self.aspect_ratio).abs().max(DVec2::new(size.y * self.aspect_ratio, size.y).abs()) * size.signum(),
				(true, false) => DVec2::new(size.y * self.aspect_ratio, size.y),
				(false, true) => DVec2::new(size.x, size.x / self.aspect_ratio),
				_ => size,
			};
		}
		if center {
			if self.left || self.right {
				size.x *= 2.;
			}
			if self.bottom || self.top {
				size.y *= 2.;
			}
		}
		[min, size]
	}
pub fn new_size ( & self , mouse : DVec2 , transform : DAffine2 , center : bool , constrain : bool ) -> [ DVec2 ; 2 ] { let mouse = transform . inverse ( ) . transform_point2 ( mouse ) ; let mut min = self . bounds [ 0 ] ; let mut max = self . bounds [ 1 ] ; if self . top { min . y = mouse . y ; } else if self . bottom { max . y = mouse . y ; } if self . left { min . x = mouse . x } else if self . right { max . x = mouse . x ; } let mut size = max - min ; if constrain { size = match ( ( self . top || self . bottom ) , ( self . left || self . right ) ) { ( true , true ) => DVec2 :: new ( size . x , size . x / self . aspect_ratio ) . abs ( ) . max ( DVec2 :: new ( size . y * self . aspect_ratio , size . y ) . abs ( ) ) * size . signum ( ) , ( true , false ) => DVec2 :: new ( size . y * self . aspect_ratio , size . y ) , ( false , true ) => DVec2 :: new ( size . x , size . x / self . aspect_ratio ) , _ => size , } ; } if center { if self . left || self . right { size . x *= 2. ; } if self . bottom || self . top { size . y *= 2. ; } } [ min , size ] }
Computes the new bounds with the given mouse move and modifier keys
Computes the new bounds with the given mouse move and modifier keys
&self
mouse
DVec2
transform
DAffine2
center
bool
constrain
bool
&self
mouse
DVec2
transform
DAffine2
center
bool
constrain
bool