Skip to content

Nvrect

NvRect

A fast rectangle class optimized for UI boundaries and collision detection.

Specific kwargs

Argument Type Description
x, y, w, h float individual components.
xy, wh NvVector2 position and size vectors.
nvrect NvRect copy constructor from another NvRect.

Methods

Name Kwargs Description
collide_rect nvrect: NvRect checks if two rectangles overlap.
collide_point x, y | xy: NvVector2 checks if a point is inside the rectangle.
move_ip x, y | xy: NvVector2 moves the rectangle in-place.
get_tuple / get_int_tuple None returns (x, y, w, h) as a tuple.
get_pygame_rect None returns a standard pygame.Rect object.

Getters

Name ReturnType Description
size NvVector2 the width and height of the rectangle.
topleft / topright NvVector2 corner coordinates.
bottomleft / bottomright NvVector2 corner coordinates.
left / top / right / bottom float edge coordinates.
xy / wh / hw / yx / xw / yh NvVector2 convenient swizzling properties.
xywh NvRect returns a copy of the rectangle.

Setters

Name Kwargs Description
size NvVector2 | tuple | list sets new width and height.
left / top / right / bottom float modifies the edge (adjusts x, y, w, or h accordingly).

Use case

from nevu_ui import *

rect = NvRect(NvVector2(100, 100), NvVector2(200, 200))
rect2 = NvRect(100, 100, 200, 200)
rect2.x = 10
nvvector = rect2.xy

Created with GGen v1.1.0 for nevu_ui v0.7.5