image
image
¶
Images and the shared textured-quad draw used by images and canvases.
draw ¶
proc draw(t: Texture; nim2d: Nim2d; x, y: float; angle: float = 0; sx: float = 1; sy: float = 1; ox: float = 0; oy: float = 0; flipH = false; flipV = false)
Draw a texture (image or canvas) with rotation/scale about origin (ox,oy).
Parameters
-
t(Texture) -
nim2d(Nim2d) -
x(float) -
y(float) -
angle(float) -
sx(float) -
sy(float) -
ox(float) -
oy(float) -
flipH(auto) -
flipV(auto)
newQuad ¶
proc newQuad(x, y, w, h, sw, sh: float): Quad
A sub-region (x, y, w, h) of a texture that is sw by sh pixels.
Parameters
-
x(float) -
y(float) -
w(float) -
h(float) -
sw(float) -
sh(float)
Returns
Quad
draw ¶
proc draw(t: Texture; nim2d: Nim2d; quad: Quad; x, y: float; angle: float = 0; sx: float = 1; sy: float = 1; ox: float = 0; oy: float = 0)
Draw just the quad region of a texture.
Parameters
-
t(Texture) -
nim2d(Nim2d) -
quad(Quad) -
x(float) -
y(float) -
angle(float) -
sx(float) -
sy(float) -
ox(float) -
oy(float)
setFilter ¶
proc setFilter(t: Texture; filter: Filter)
Choose smooth sampling (filLinear, the default) or sharp, blocky sampling
(filNearest), which keeps pixel art crisp when scaled up.
Parameters
-
t(Texture) -
filter(Filter)
setWrap ¶
proc setWrap(t: Texture; wrap: Wrap)
Choose how texcoords outside 0..1 behave: clamp to the edge (the default),
repeat, or mirror. Repeat is what you want for a tiling texture.
Parameters
-
t(Texture) -
wrap(Wrap)
newImage ¶
proc newImage(nim2d: Nim2d; filename: string; mipmaps = false): Image
Load an image file into a drawable GPU texture. PNG, JPEG and the other
formats SDL_image reads all work. mipmaps builds a mipmap chain, which
stops the texture shimmering when drawn much smaller than its native
size. Raises IOError when the file cannot be loaded.
Parameters
-
nim2d(Nim2d) -
filename(string) -
mipmaps(auto)
Returns
Image
setColorMod ¶
proc setColorMod(t: Texture; r, g, b: uint8)
Tint the texture: its colors are multiplied by these channels when drawn.
Parameters
-
t(Texture) -
r(uint8) -
g(uint8) -
b(uint8)
setAlphaMod ¶
proc setAlphaMod(t: Texture; a: uint8)
Fade the texture: 255 is fully opaque, 0 invisible.
Parameters
-
t(Texture) -
a(uint8)
getWidth ¶
proc getWidth(t: Texture): int32
getHeight ¶
proc getHeight(t: Texture): int32
The texture's height in pixels.
Parameters
-
t(Texture)
Returns
int32
getDimensions ¶
proc getDimensions(t: Texture): tuple[w, h: int32]
The texture's width and height in pixels.
Parameters
-
t(Texture)
Returns
tuple[w, h: int32]
destroy ¶
proc destroy(nim2d: Nim2d; t: Texture)
Free the GPU texture. The object is unusable afterwards; this exists for
releasing memory early, since textures otherwise live until the engine shuts down.
Parameters
-
nim2d(Nim2d) -
t(Texture)