texturegraphic

Types

TextureGraphic = ref object of Graphic
  fTexture: sdl.Texture
  fFormat: uint32
  fSize: Dim

Procs

proc freeTexture(graphic: TextureGraphic) {...}{.raises: [], tags: [].}
proc free(graphic: TextureGraphic) {...}{.raises: [], tags: [].}
proc init(graphic: TextureGraphic) {...}{.raises: [], tags: [].}
proc updateTexture(graphic: TextureGraphic): bool {...}{.raises: [Exception],
    tags: [RootEffect].}
proc format(graphic: TextureGraphic): uint32 {...}{.inline, raises: [], tags: [].}
proc load(graphic: TextureGraphic; file: string): bool {...}{.raises: [Exception],
    tags: [RootEffect].}

Load texture from file.

Return true on success, false otherwise.

proc load(graphic: TextureGraphic; rw: ptr RWops; freeSrc: bool = true): bool {...}{.
    raises: [Exception], tags: [RootEffect].}

Load texture from src RWops.

Return true on success, false otherwise.

proc assignTexture(graphic: TextureGraphic; texture: Texture;
                  freeCurrent: bool = true): bool {...}{.raises: [Exception],
    tags: [RootEffect].}

Assign already created texture.

freeCurrent Free the currently assigned texture. Set to false if it used by other objects.

ATTENTION! The texture will be destroyed on free().

Return true on success, false otherwise.

proc texture(graphic: TextureGraphic): sdl.Texture {...}{.inline, raises: [], tags: [].}
Direct access to the graphic's texture. Be careful.
proc newTextureGraphic(): TextureGraphic {...}{.raises: [], tags: [].}
proc newTextureGraphic(file: string): TextureGraphic {...}{.raises: [Exception],
    tags: [RootEffect].}
proc newTextureGraphic(src: ptr RWops; freeSrc: bool = true): TextureGraphic {...}{.
    raises: [Exception], tags: [RootEffect].}
proc newTextureGraphic(texture: Texture): TextureGraphic {...}{.raises: [Exception],
    tags: [RootEffect].}
proc drawTextureGraphic(graphic: TextureGraphic; pos: Coord = (0.0, 0.0);
                       angle: Angle = 0.0; scale: Scale = 1.0;
                       center: Coord = (0.0, 0.0); flip: Flip = Flip.none;
                       region: Rect = Rect(x: 0, y: 0, w: 0, h: 0)) {...}{.raises: [Exception],
    tags: [RootEffect].}

Draw procedure.

pos Draw coordinates.

angle Rotation angle in degrees.

scale Draw scale. 1.0 for original size.

center Center of rendering, rotation, and scaling.

flip RendererFlip value, could be set to: FlipNone, FlipHorizontal, FlipVertical.

region Source texture region to draw.

proc drawTiled(graphic: TextureGraphic; rect: Rect;
              region: Rect = Rect(x: 0, y: 0, w: 0, h: 0); reverseX = false; reverseY = false) {...}{.
    raises: [Exception], tags: [RootEffect].}

Repeatedly draw the graphic to fill the rect.

region Source texture region to draw.

reverseX, reverseY Drawing progression order.

proc colorMod(graphic: TextureGraphic): Color {...}{.raises: [], tags: [].}
Return current color modifier.
proc colorMod=(graphic: TextureGraphic; color: Color) {...}{.raises: [], tags: [].}
Set a new color modifier.
proc alphaMod(graphic: TextureGraphic): uint8 {...}{.raises: [], tags: [].}
Return current alpha (transparency) modifier.
proc alphaMod=(graphic: TextureGraphic; alpha: uint8) {...}{.raises: [], tags: [].}
Set a new alpha (transparency) modifier.
proc blendMod(graphic: TextureGraphic): Blend {...}{.raises: [], tags: [].}
Return current blending mode.
proc blendMod=(graphic: TextureGraphic; blend: Blend) {...}{.raises: [], tags: [].}
Set a new blending mode.

Methods

method w(graphic: TextureGraphic): int {...}{.inline, raises: [], tags: [].}
method h(graphic: TextureGraphic): int {...}{.inline, raises: [], tags: [].}
method dim(graphic: TextureGraphic): Dim {...}{.inline, raises: [], tags: [].}
method draw(graphic: TextureGraphic; pos: Coord = (0.0, 0.0); angle: Angle = 0.0;
           scale: Scale = 1.0; center: Coord = (0.0, 0.0); flip: Flip = Flip.none;
           region: Rect = Rect(x: 0, y: 0, w: 0, h: 0)) {...}{.raises: [Exception],
    tags: [RootEffect].}