S or /

SourceClass Vec2

from egui import Vec2
class Vec2:

A vector has a direction and length. A Vec2 is often used to represent a size.

emath represents positions using egui.Pos2.

Normally the units are points (logical pixels).

Properties§

@property def x(self, /) -> float§
@x.setter def x(self, /, x: float) -> None§
@property def y(self, /) -> float§
@y.setter def y(self, /, y: float) -> None§

Methods§

Sourcedef abs(self, /) -> Vec2§
Sourcedef angle(self, /) -> float§

Measures the angle of the vector.

Source@staticmethod def angled(angle: float) -> Vec2§

Create a unit vector with the given CW angle (in radians). * An angle of zero gives the unit X axis. * An angle of 𝞃/4 = 90° gives the unit Y axis.

Sourcedef any_nan(self, /) -> bool§

True if any member is NaN.

def at_least(self, /, lower_limit: Vec2) -> Vec2§
def at_most(self, /, upper_limit: Vec2) -> Vec2§
Sourcedef ceil(self, /) -> Vec2§
Sourcedef clamp(self, /, min: Vec2, max: Vec2) -> Vec2§
Sourcedef dot(self, /, other: Vec2) -> float§

The dot-product of two vectors.

Sourcedef floor(self, /) -> Vec2§
Sourcedef is_finite(self, /) -> bool§

True if all members are also finite.

Sourcedef is_normalized(self, /) -> bool§

Checks if self has length 1.0 up to a precision of 1e-6.

Sourcedef length(self, /) -> float§
Sourcedef length_sq(self, /) -> float§
Sourcedef max(self, /, other: Vec2) -> Vec2§
Sourcedef max_elem(self, /) -> float§

Returns the maximum of egui.x and egui.y.

Sourcedef min(self, /, other: Vec2) -> Vec2§
Sourcedef min_elem(self, /) -> float§

Returns the minimum of egui.x and egui.y.

Sourcedef normalized(self, /) -> Vec2§

Safe normalize: returns zero if input is zero.

Sourcedef rot90(self, /) -> Vec2§

Rotates the vector by 90°, i.e positive X to positive Y (clockwise in egui coordinates).

Sourcedef round(self, /) -> Vec2§
Source@staticmethod def splat(value: float) -> Vec2§

Set both x and y to the same value.

Sourcedef to_pos2(self, /) -> Pos2§

Treat this vector as a position. v.to_pos2() is equivalent to Pos2.default() + v.

Sourcedef yx(self, /) -> Vec2§

Swizzle the axes.

@staticmethod def zero() -> Vec2§