Module utils

Types

Point = tuple[x, y: int]
Size = tuple[w, h: int]
Region = tuple[x, y, w, h: int]
Resolution = object
  width*, height*: int

Procs

proc weighted_choice[T](options: seq[(int, T)];
                       rng: var MersenneTwister = mersenneTwisterInst): T
Return a T from a seq[(int, T)] where the first item in each tuple specifies a relative likelyhood, or weight, of that item being selected.
proc weighted_selection[T](options: seq[(int, T)]; selection: float): T
Return a T from a seq[(int, T)] based on the input selection. The selection is a float between 0.0 and 1.0. To determine the option to return a sum of all option weights is created. The selection value is mapped to the range of zero to the sum and the associated option is returned.
proc merge[K, V](d1: var Table[K, V]; d2: Table[K, V])

Converters

converter cint2int(x: cint): int {.raises: [], tags: [].}
converter int2cint(x: int): cint {.raises: [], tags: [].}
converter uint2int(x: uint): int {.raises: [], tags: [].}
converter int2uint(x: int): uint {.raises: [], tags: [].}