pub struct PixelVector {
pub x: i32,
pub y: i32,
}Expand description
Defines a vector in device pixels. Integer arithmetic wraps on overflow.
Fields§
§x: i32The X component.
y: i32The Y component.
Implementations§
Source§impl PixelVector
impl PixelVector
Sourcepub const fn new(x: i32, y: i32) -> Self
pub const fn new(x: i32, y: i32) -> Self
Initializes a new instance of the PixelVector structure.
Sourcepub fn length(&self) -> f64
pub fn length(&self) -> f64
Length of the vector. The squared length is computed in (wrapping) 32-bit integer arithmetic, so very large vectors yield NaN or a wrapped length.
Sourcepub const fn equals(&self, other: PixelVector) -> bool
pub const fn equals(&self, other: PixelVector) -> bool
Check if two vectors are equal (bitwise).
Sourcepub fn nearly_equals(&self, other: PixelVector) -> bool
pub fn nearly_equals(&self, other: PixelVector) -> bool
Check if two vectors are nearly equal (numerically). For integer components this is the same as equality.
§Panics
Panics if a component difference is i32::MIN, whose absolute value is not
representable.
Sourcepub const fn with_x(&self, x: i32) -> PixelVector
pub const fn with_x(&self, x: i32) -> PixelVector
Returns a new vector with the specified X component.
Sourcepub const fn with_y(&self, y: i32) -> PixelVector
pub const fn with_y(&self, y: i32) -> PixelVector
Returns a new vector with the specified Y component.
Trait Implementations§
Source§impl Add for PixelVector
impl Add for PixelVector
Source§type Output = PixelVector
type Output = PixelVector
+ operator.Source§fn add(self, b: PixelVector) -> PixelVector
fn add(self, b: PixelVector) -> PixelVector
+ operation. Read moreSource§impl Add<PixelVector> for PixelPoint
impl Add<PixelVector> for PixelPoint
Source§type Output = PixelPoint
type Output = PixelPoint
+ operator.Source§fn add(self, b: PixelVector) -> PixelPoint
fn add(self, b: PixelVector) -> PixelPoint
+ operation. Read moreSource§impl AddAssign for PixelVector
impl AddAssign for PixelVector
Source§fn add_assign(&mut self, b: PixelVector)
fn add_assign(&mut self, b: PixelVector)
+= operation. Read moreSource§impl AddAssign<PixelVector> for PixelPoint
impl AddAssign<PixelVector> for PixelPoint
Source§fn add_assign(&mut self, b: PixelVector)
fn add_assign(&mut self, b: PixelVector)
+= operation. Read moreSource§impl Clone for PixelVector
impl Clone for PixelVector
impl Copy for PixelVector
Source§impl Debug for PixelVector
impl Debug for PixelVector
Source§impl Default for PixelVector
impl Default for PixelVector
Source§impl Display for PixelVector
impl Display for PixelVector
Source§impl Div<i32> for PixelVector
Scales a vector.
impl Div<i32> for PixelVector
Scales a vector.
§Panics
Panics on division by zero and on i32::MIN / -1.
Source§type Output = PixelVector
type Output = PixelVector
/ operator.Source§impl DivAssign<i32> for PixelVector
impl DivAssign<i32> for PixelVector
Source§fn div_assign(&mut self, scale: i32)
fn div_assign(&mut self, scale: i32)
/= operation. Read moreimpl Eq for PixelVector
Source§impl From<PixelPoint> for PixelVector
Converts the PixelPoint to a PixelVector.
impl From<PixelPoint> for PixelVector
Converts the PixelPoint to a PixelVector.
Source§fn from(p: PixelPoint) -> PixelVector
fn from(p: PixelPoint) -> PixelVector
Source§impl From<PixelVector> for PixelPoint
Converts the PixelVector to a PixelPoint (an explicit conversion in the
reference API).
impl From<PixelVector> for PixelPoint
Converts the PixelVector to a PixelPoint (an explicit conversion in the
reference API).
Source§fn from(a: PixelVector) -> PixelPoint
fn from(a: PixelVector) -> PixelPoint
Source§impl Hash for PixelVector
impl Hash for PixelVector
Source§impl MarkupTyped for PixelVector
impl MarkupTyped for PixelVector
Source§const MARKUP: &'static MarkupType
const MARKUP: &'static MarkupType
Source§impl Mul for PixelVector
Calculates the dot product of two vectors.
impl Mul for PixelVector
Calculates the dot product of two vectors.
Source§impl Mul<i32> for PixelVector
Scales a vector.
impl Mul<i32> for PixelVector
Scales a vector.
Source§type Output = PixelVector
type Output = PixelVector
* operator.Source§impl MulAssign<i32> for PixelVector
impl MulAssign<i32> for PixelVector
Source§fn mul_assign(&mut self, scale: i32)
fn mul_assign(&mut self, scale: i32)
*= operation. Read moreSource§impl Neg for PixelVector
impl Neg for PixelVector
Source§type Output = PixelVector
type Output = PixelVector
- operator.Source§fn neg(self) -> PixelVector
fn neg(self) -> PixelVector
- operation. Read moreSource§impl PartialEq for PixelVector
impl PartialEq for PixelVector
impl StructuralPartialEq for PixelVector
Source§impl Sub for PixelVector
impl Sub for PixelVector
Source§type Output = PixelVector
type Output = PixelVector
- operator.Source§fn sub(self, b: PixelVector) -> PixelVector
fn sub(self, b: PixelVector) -> PixelVector
- operation. Read moreSource§impl Sub<PixelVector> for PixelPoint
impl Sub<PixelVector> for PixelPoint
Source§type Output = PixelPoint
type Output = PixelPoint
- operator.Source§fn sub(self, b: PixelVector) -> PixelPoint
fn sub(self, b: PixelVector) -> PixelPoint
- operation. Read moreSource§impl SubAssign for PixelVector
impl SubAssign for PixelVector
Source§fn sub_assign(&mut self, b: PixelVector)
fn sub_assign(&mut self, b: PixelVector)
-= operation. Read moreSource§impl SubAssign<PixelVector> for PixelPoint
impl SubAssign<PixelVector> for PixelPoint
Source§fn sub_assign(&mut self, b: PixelVector)
fn sub_assign(&mut self, b: PixelVector)
-= operation. Read moreAuto Trait Implementations§
impl Freeze for PixelVector
impl RefUnwindSafe for PixelVector
impl Send for PixelVector
impl Sync for PixelVector
impl Unpin for PixelVector
impl UnsafeUnpin for PixelVector
impl UnwindSafe for PixelVector
Blanket Implementations§
Source§impl<T> AnyValue for Twhere
T: PartialEq + 'static,
impl<T> AnyValue for Twhere
T: PartialEq + 'static,
fn any_value_as_any(&self) -> &(dyn Any + 'static)
fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool
fn any_value_type_name(&self) -> &'static str
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
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more