# nodesnim/nodes2d/node2d

Dark Mode

Search:
Group by:

The base of other 2D nodes.

# Imports

../thirdparty/opengl, ../core/vector2, ../core/rect2, ../core/anchor, ../core/input, ../core/enums, ../nodes/node, ../nodes/canvas

# Types

    Node2DObj = object of CanvasObj
      centered*: bool
      rotation*: float
      scale*: Vector2Ref
      timed_position*: Vector2Ref

    Node2DRef = ref Node2DObj

# Procs

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

  Creates a new Node2D.

  Arguments:

  - `name` is a node name.

  Examples:

      var node = Node2D("Node2D")

# Methods

    method draw(self: Node2DRef; w, h: GLfloat) {...}{.raises: [], tags: [].}

  this method uses in the `window.nim`.

    method move(self: Node2DRef; x, y: float) {...}{.raises: [], tags: [].}

  Moves Node2D object by `x` and `y`.

    method move(self: Node2DRef; vec2: Vector2Ref) {...}{.raises: [], tags: [].}

  Moves Node2D object by `vec2`.

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

  Duplicates Node2D object and create a new Node2D.

    method getGlobalMousePosition(self: Node2DRef): Vector2Ref {...}{.base, inline, raises: [],
        tags: [].}

  Returns mouse position.

    method setZIndex(self: Node2DRef; z_index: int) {...}{.base, raises: [], tags: [].}

  Changes Z index.

# Templates

    template node2dpattern(): untyped