# PixelVector

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/struct-pixelvector/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct PixelVector
```

Defines a vector in device pixels. Integer arithmetic wraps on overflow.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/pixel_vector.rs#L10)

## Members

- [`x`](#struct_field-x)
- [`y`](#struct_field-y)
- [`new`](#function-new)
- [`length`](#function-length)
- [`equals`](#function-equals)
- [`nearly_equals`](#function-nearly_equals)
- [`with_x`](#function-with_x)
- [`with_y`](#function-with_y)

<a id="struct_field-x"></a>

### x

```rust
x: i32
```

The X component.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/pixel_vector.rs#L12)

<a id="struct_field-y"></a>

### y

```rust
y: i32
```

The Y component.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/pixel_vector.rs#L14)

<a id="function-new"></a>

### new

```rust
const fn new(x: i32, y: i32) -> Self
```

Initializes a new instance of the `PixelVector` structure.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/pixel_vector.rs#L20)

<a id="function-length"></a>

### length

```rust
fn length(self: &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.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/pixel_vector.rs#L27)

<a id="function-equals"></a>

### equals

```rust
const fn equals(self: &Self, other: PixelVector) -> bool
```

Check if two vectors are equal (bitwise).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/pixel_vector.rs#L37)

<a id="function-nearly_equals"></a>

### nearly_equals

```rust
fn nearly_equals(self: &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.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/pixel_vector.rs#L47)

<a id="function-with_x"></a>

### with_x

```rust
const fn with_x(self: &Self, x: i32) -> PixelVector
```

Returns a new vector with the specified X component.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/pixel_vector.rs#L59)

<a id="function-with_y"></a>

### with_y

```rust
const fn with_y(self: &Self, y: i32) -> PixelVector
```

Returns a new vector with the specified Y component.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/pixel_vector.rs#L65)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ResourceKeyObject`](/docs/0.5.0/api/ferroui-base/controls/trait-resourcekeyobject/)
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ToString`
- `ErasedDestructor`
- `IntoEither`
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)
- [`ValueTypeRegistration`](/docs/0.5.0/api/ferroui-base/data/core/trait-valuetyperegistration/)
- `From<PixelPoint>`
- `Add<PixelVector>`
- `Sub<PixelVector>`
- `AddAssign<PixelVector>`
- `SubAssign<PixelVector>`
- `Clone`
- `Copy`
- `Debug`
- `StructuralPartialEq`
- `PartialEq`
- `Eq`
- `Hash`
- `Default`
- `From<PixelVector>`
- `Mul`
- `Mul<i32>`
- `Div<i32>`
- `Neg`
- `Add`
- `Sub`
- `AddAssign`
- `SubAssign`
- `MulAssign<i32>`
- `DivAssign<i32>`
- `Display`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
