Table of Contents

Struct PixelVector

Namespace
Avalonia
Assembly
Avalonia.Base.dll

Defines a vector.

public readonly struct PixelVector
Inherited Members

Constructors

PixelVector(int, int)

Initializes a new instance of the PixelVector structure.

public PixelVector(int x, int y)

Parameters

x int

The X vector.

y int

The Y vector.

Properties

Length

Length of the vector

public double Length { get; }

Property Value

double

X

Gets the X vector.

public int X { get; }

Property Value

int

Y

Gets the Y vector.

public int Y { get; }

Property Value

int

Methods

Equals(PixelVector)

Check if two vectors are equal (bitwise).

public bool Equals(PixelVector other)

Parameters

other PixelVector

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

NearlyEquals(PixelVector)

Check if two vectors are nearly equal (numerically).

public bool NearlyEquals(PixelVector other)

Parameters

other PixelVector

The other vector.

Returns

bool

True if vectors are nearly equal.

ToString()

Returns the string representation of the point.

public override string ToString()

Returns

string

The string representation of the point.

WithX(int)

Returns a new vector with the specified X coordinate.

public PixelVector WithX(int x)

Parameters

x int

The X coordinate.

Returns

PixelVector

The new vector.

WithY(int)

Returns a new vector with the specified Y coordinate.

public PixelVector WithY(int y)

Parameters

y int

The Y coordinate.

Returns

PixelVector

The new vector.

Operators

operator +(PixelVector, PixelVector)

Adds two vectors.

public static PixelVector operator +(PixelVector a, PixelVector b)

Parameters

a PixelVector

The first vector.

b PixelVector

The second vector.

Returns

PixelVector

A vector that is the result of the addition.

operator /(PixelVector, int)

Scales a vector.

public static PixelVector operator /(PixelVector vector, int scale)

Parameters

vector PixelVector

The vector

scale int

The divisor.

Returns

PixelVector

The scaled vector.

operator ==(PixelVector, PixelVector)

public static bool operator ==(PixelVector left, PixelVector right)

Parameters

left PixelVector
right PixelVector

Returns

bool

explicit operator PixelPoint(PixelVector)

Converts the PixelVector to a PixelPoint.

public static explicit operator PixelPoint(PixelVector a)

Parameters

a PixelVector

The vector.

Returns

PixelPoint

operator !=(PixelVector, PixelVector)

public static bool operator !=(PixelVector left, PixelVector right)

Parameters

left PixelVector
right PixelVector

Returns

bool

operator *(PixelVector, PixelVector)

Calculates the dot product of two vectors

public static int operator *(PixelVector a, PixelVector b)

Parameters

a PixelVector

First vector

b PixelVector

Second vector

Returns

int

The dot product

operator *(PixelVector, int)

Scales a vector.

public static PixelVector operator *(PixelVector vector, int scale)

Parameters

vector PixelVector

The vector

scale int

The scaling factor.

Returns

PixelVector

The scaled vector.

operator -(PixelVector, PixelVector)

Subtracts two vectors.

public static PixelVector operator -(PixelVector a, PixelVector b)

Parameters

a PixelVector

The first vector.

b PixelVector

The second vector.

Returns

PixelVector

A vector that is the result of the subtraction.

operator -(PixelVector)

Negates a vector.

public static PixelVector operator -(PixelVector a)

Parameters

a PixelVector

The vector.

Returns

PixelVector

The negated vector.