Module rect

rect.nim

Header file for Rect definition and management procedures.

Types

Point* = object
  x*: cint
  y*: cint

The object that defines a point

See also:

enclosePoints()

pointInRect()

Rect* = object
  x*: cint
  y*: cint
  w*: cint
  h*: cint

A rectangle, with the origin at the upper left.

See also:

rectEmpty()

rectEquals()

hasIntersection()

intersectRect()

unionRect()

enclosePoints()

Procs

proc hasIntersection*(a: ptr Rect; b: ptr Rect): bool {.cdecl,
    importc: "SDL_HasIntersection", dynlib: SDL2_LIB.}

Determine whether two rectangles intersect.

Return true if there is an intersection, false otherwise.

proc intersectRect*(a: ptr Rect; b: ptr Rect; result: ptr Rect): bool {.cdecl,
    importc: "SDL_IntersectRect", dynlib: SDL2_LIB.}

Calculate the intersection of two rectangles.

Return true if there is an intersection, false otherwise.

proc unionRect*(a: ptr Rect; b: ptr Rect; result: ptr Rect) {.cdecl,
    importc: "SDL_UnionRect", dynlib: SDL2_LIB.}
Calculate the union of two rectangles.
proc enclosePoints*(points: ptr Point; count: cint; clip: ptr Rect; result: ptr Rect): bool {.
    cdecl, importc: "SDL_EnclosePoints", dynlib: SDL2_LIB.}

Calculate a minimal rectangle enclosing a set of points.

Return true if any points were within the clipping rect.

proc intersectRectAndLine*(rect: ptr Rect; x1: ptr cint; y1: ptr cint; x2: ptr cint;
                          y2: ptr cint): bool {.cdecl,
    importc: "SDL_IntersectRectAndLine", dynlib: SDL2_LIB.}

Calculate the intersection of a rectangle and line segment.

Return true if there is an intersection, false otherwise.

Templates

template pointInRect*(p: expr; r: expr): bool
Return true if point resides inside a rectangle.
template rectEmpty*(r: expr): bool
Return true if the rectangle has no area.
template rectEquals*(a: expr; b: expr): bool
Return true if the two rectangles are equal.