Procs
proc distance(a, b: Coord): float {...}{.inline, raises: [], tags: [].}
- Return distance between two coordinates.
proc distanceToLine(a, d1, d2: Coord): float {...}{.raises: [], tags: [].}
- Return distance between point a and line d1-d2.
proc direction(a, b: Coord): Angle {...}{.raises: [], tags: [].}
- Return angle direction from coordinate a to b (in degrees).
proc rotate(a: Coord; angle: Angle): Coord {...}{.raises: [], tags: [].}
- Rotate point a by the given angle (in degrees).
proc rotate(point, offset: Coord; angle: Angle): Coord {...}{.raises: [], tags: [].}
-
Rotate point by the given angle and with given offset.
offset Offset coordinate (parent position) point Point to rotate angle Angle of rotation (in degrees)
proc loadSurface(file: string): Surface {...}{.raises: [], tags: [].}
-
Load an image file to the sdl.Surface.
Return the surface on success, or nil otherwise.
proc loadSurface(src: ptr RWops; freeSrc: bool = true): Surface {...}{.raises: [], tags: [].}
-
Load src RWops to the sdl.Surface.
Return the surface on success, or nil otherwise.
proc textureFormats(renderer: Renderer): tuple[num: uint32, formats: array[16, uint32]] {...}{.raises: [], tags: [].}
- Return number and array of available texture formats from the renderer.
proc textureFormat(renderer: Renderer; n: uint32 = 0): uint32 {...}{.raises: [], tags: [].}
- Return n'th texture format from the renderer.
proc readAll(src: ptr RWops): string {...}{.raises: [Exception], tags: [RootEffect].}
proc loadCSV[T](file: string; parse: proc (input: string): T; separator = ','; quote = '\"'; escape = '\x00'; skipInitialSpace = true): seq[seq[T]]
-
Load data from a CSV file.
Return a two-dimensional sequence of values from the file, or empty sequence (@[]) otherwise.
proc loadCSV[T](src: ptr RWops; file: string; parse: proc (input: string): T; separator = ','; quote = '\"'; escape = '\x00'; skipInitialSpace = true; freeSrc = true): seq[seq[T]]
-
Load data from src RWops.
file is only used for nice error messages.
Return a two-dimensional sequence of values from the file, or empty sequence (@[]) otherwise.
proc loadPalette(palette: var indexedimage.Palette; file: string; separator = ' '; quote = '\"'; escape = '\x00'; skipInitialSpace = true) {...}{. raises: [CsvError, Exception, OverflowError, ValueError, IndexError], tags: [ReadIOEffect].}
-
Load palette color data from a file.
palette Target palette. If palette is nil, allocates a new palette, otherwise the palette will be freed.
Data file should be in a format of:
rrr ggg bbb aaa ...
or
rrr ggg bbb
where rrr, ggg, bbb, and aaa is in 0..`255` range.
Other types of lines are ignored.
proc loadPalette(palette: var indexedimage.Palette; src: ptr RWops; file: string; separator = ' '; quote = '\"'; escape = '\x00'; skipInitialSpace = true; freeSrc = true) {...}{.raises: [Exception, CsvError, OverflowError, ValueError, IndexError], tags: [RootEffect, ReadIOEffect].}
proc random[T](max: T; exclude: seq[T]): T {...}{.deprecated.}
-
Return a random number in the range 0..<max, except values in the exclude.
Deprecated: Use rand instead.
proc rand[T](max: T; exclude: seq[T]): T
- Return a random number in the range 0..``max``, except values in the exclude.
proc rand[T](max: T; exclude: openArray[T]): T {...}{.inline.}
proc random[T](x, exclude: seq[T]): T {...}{.deprecated.}
-
Return a random number in the sequence x, except values in the exclude.
Deprecated: use rand instaead.
proc rand[T](x, exclude: seq[T]): T
- Return a random number in the sequence x, except values in the exclude.
proc rand[T](x, exclude: openArray[T]): T {...}{.inline.}
proc random[T](x: Slice[T]; exclude: seq[T]): T {...}{.deprecated.}
-
Return a random number in the range min..<max, except values in the exclude.
Deprecated: use rand instead.
proc rand[T](x: Slice[T]; exclude: seq[T]): T
- Return a random number in the range min..``max``, except values in the exclude.
proc rand[T](x: Slice[T]; exclude: openArray[T]): T {...}{.inline.}
proc random[T](x: set[T]): T {...}{.deprecated.}
-
Return a random member of set x.
Deprecated: use rand instead.
proc rand[T](x: set[T]): T
- Return a random member of set x.
proc randomBool(chance: float = 0.5): bool {...}{.deprecated, raises: [], tags: [].}
- Return true or false, based on the chance value (from 0.0 to 1.0).
proc randBool(chance: float = 0.5): bool {...}{.inline, raises: [], tags: [].}
proc randomSign(chance: float = 0.5): int {...}{.raises: [], tags: [].}
- Return 1 or -1, based on the chance value (from 0.0 to 1.0).
proc randSign(chance: float = 0.5): int {...}{.inline, raises: [], tags: [].}
proc randomWeighted[T](weights: openArray[T]): int
-
Return a random integer, based on the weights array.
E.g., call of randomWeighted([2, 3, 5]) will have a 20% chance of returning 0, 30% chance of returning 1, and 50% chance of returning 2.
proc randWeighted[T](weights: openArray[T]): int {...}{.inline.}
proc newCounter(interval: int = 1000): Counter {...}{.raises: [], tags: [].}
proc update(counter: Counter) {...}{.raises: [], tags: [].}
proc value(counter: Counter): int {...}{.inline, raises: [], tags: [].}
Iterators
iterator atlasValues(file: string; separator = ','; quote = '\"'; escape = '\x00'; skipInitialSpace = true): tuple[name: string, rect: Rect] {...}{. raises: [CsvError, Exception, OverflowError, ValueError], tags: [ReadIOEffect].}
-
Load and iterate over atlas mapping file.
Mapping should be in a format of:
name, x, y, w, h ...
iterator atlasValues(src: ptr RWops; file: string; separator = ','; quote = '\"'; escape = '\x00'; skipInitialSpace = true; freeSrc = true): tuple[ name: string, rect: Rect] {...}{.raises: [Exception, CsvError, OverflowError, ValueError], tags: [RootEffect, ReadIOEffect].}
Templates
template rad(a: Angle): Angle
- Convert degrees to radians.
template deg(a: Angle): Angle
- Convert radians to degrees.
template random[T](max: T; exclude: openArray[T]): T {...}{.deprecated.}
template random[T](x, exclude: openArray[T]): T {...}{.deprecated.}
template random[T](x: Slice[T]; exclude: openArray[T]): T {...}{.deprecated.}
template timeDiff(first, second: untyped): untyped
-
first, second two results of sdl.getPerformanceCounter().
Return time difference between two time stamps (in ms).
template msToSec(ms: int): float
template secToMs(sec: float): int