# nodesnim/nodescontrol/texture_rect

Dark Mode

Search:
Group by:

It provides a primitive display image.

# Imports

../thirdparty/opengl, ../core/vector2, ../core/rect2, ../core/anchor, ../core/input, ../core/image, ../core/enums, ../core/color, ../nodes/node, control

# Types

    TextureRectObj = object of ControlRef
      texture*: GLuint
      texture_mode*: TextureMode
      texture_size*: Vector2Ref
      texture_anchor*: AnchorRef
      texture_filter*: ColorRef

    TextureRectRef = ref TextureRectObj

# Procs

    proc TextureRect(name: string = "TextureRect"): TextureRectRef {...}{.raises: [], tags: [].}

  Creates a new TextureRect.

  Arguments:

  - `name` is a node name.

  Examples:

      var texture = TextureRect("TextureRect")

# Methods

    method draw(self: TextureRectRef; w, h: GLfloat) {...}{.raises: [GLerror, Exception],
        tags: [RootEffect].}

  This uses in the `window.nim`.

    method duplicate(self: TextureRectRef): TextureRectRef {...}{.base, raises: [], tags: [].}

  Duplicates TextureRect and create a new TextureRect.

    method loadTexture(self: TextureRectRef; file: cstring) {...}{.base, raises: [GLerror],
        tags: [].}

  Loads texture from file.

  Arguments:

  - `file` is an image file path.

    method setTexture(self: TextureRectRef; gltexture: GlTextureObj) {...}{.base, raises: [],
        tags: [].}

  Changes texture.

  Arguments:

  - `gltexture` is a texture, loaded via load(file, mode=GL_RGB).

    method setTextureFilter(self: TextureRectRef; color: ColorRef) {...}{.base, raises: [],
        tags: [].}

  Changes texture filter color.

    method setTextureAnchor(self: TextureRectRef; anchor: AnchorRef) {...}{.base, raises: [],
        tags: [].}

  Changes texture anchor.

    method setTextureAnchor(self: TextureRectRef; x1, y1, x2, y2: float) {...}{.base, raises: [],
        tags: [].}

  Changes texture anchor.

  ARguments:

  - `x1` and `y1` is an anchor relative to TextureRect size.
  - `x2` and `y2` is an anchor relative to texture size.