Nvvector2
NvVector2
A high-performance 2D vector class optimized with Cython for fast UI calculations.
Specific kwargs
| Argument |
Type |
Description |
x |
float |
x coordinate (default is 0.0). |
y |
float |
y coordinate (default is 0.0). |
vector / sequence |
Any |
can be initialized from another NvVector2, pygame.Vector2, list or tuple. |
Methods
| Name |
Kwargs |
Description |
copy |
None |
returns a copy of the vector. |
to_tuple / get_int_tuple |
None |
returns vector data as a tuple. |
to_pygame |
None |
converts to pygame.Vector2 object. |
normalize / normalize_ip |
None |
returns normalized vector (ip = in place). |
distance_to |
other: NvVector2 |
calculates Euclidean distance. |
dot |
other: NvVector2 |
calculates dot product. |
get_int / get_round / get_abs / get_neg |
None |
returns a new modified vector. |
to_int / to_round / to_abs / to_neg |
None |
modifies current vector in place. |
Static methods
| Name |
Kwargs |
ReturnType |
Description |
from_xy / from_ints / from_floats |
x, y |
NvVector2 |
creates vector from two values. |
from_list / from_tuple |
sequence |
NvVector2 |
creates vector from a sequence. |
Getters
| Name |
ReturnType |
Description |
x |
float |
x coordinate. |
y |
float |
y coordinate. |
length |
float |
magnitude of the vector. |
xy / yx / xx / yy |
NvVector2 |
swizzling properties (returns a new vector). |
Use case
from nevu_ui import *
vector = NvVector(2, 2)
vector2 = NvVector2(vector)
vector3 = NvVector2((100, 100))
vector3.x = 10
Created with GGen v1.1.0 for nevu_ui v0.7.5