# IDraw2D

`com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D`

**Since:** 1.2.7

A 2D overlay that holds render elements; implemented by standalone overlays and screens.  
 
 Both implementations expose the same element API.  
 
 ```js
// a plain overlay, the usual implementation
const draw = Hud.createDraw2D();  
draw.addText("hello", 10, 10, Color.rgb(0xFF, 0xFF, 0xFF), true);  
draw.register();  
 ```

## Type Parameters

- `T`: the type returned by removal methods

## Methods

### addDraw2D {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addDraw2D-Draw2D-int-int-int-int-}

```js
addDraw2D(Draw2D draw2D, int x, int y, int width, int height): Draw2DElement
```

Adds another overlay as a child, or returns `null` if that would create a cycle.

**Parameters:**
- `draw2D`: the overlay to draw inside this one
- `x`: the x position on this draw2d
- `y`: the y position on this draw2d
- `width`: the nested overlay's width
- `height`: the nested overlay's height

**Returns:** a wrapper for the nested overlay, or `null` if nesting would create a cycle

**Since:** 1.8.4

### addDraw2D {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addDraw2D-Draw2D-int-int-int-int-int-}

```js
addDraw2D(Draw2D draw2D, int x, int y, int width, int height, int zIndex): Draw2DElement
```

Adds another overlay as a child with the specified draw order, or returns `null` if that would create a cycle.

**Parameters:**
- `draw2D`: the overlay to draw inside this one
- `x`: the x position on this draw2d
- `y`: the y position on this draw2d
- `width`: the nested overlay's width
- `height`: the nested overlay's height
- `zIndex`: the nested overlay's draw order among this overlay's elements

**Returns:** a wrapper for the nested overlay, or `null` if nesting would create a cycle

**Since:** 1.8.4

### addImage {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addImage-int-int-int-int-String-int-int-int-int-int-int-}

```js
addImage(int x, int y, int width, int height, String id, int imageX, int imageY, int regionWidth, int regionHeight, int textureWidth, int textureHeight): Image
```

Adds an unrotated texture region as an image with the default z-index and white tint.

**Parameters:**
- `x`: image's screen-space left edge
- `y`: image's screen-space top edge
- `width`: displayed width in screen pixels
- `height`: displayed height in screen pixels
- `id`: texture identifier
- `imageX`: region's left coordinate in the texture
- `imageY`: region's top coordinate in the texture
- `regionWidth`: region width in texture pixels
- `regionHeight`: region height in texture pixels
- `textureWidth`: full texture width in pixels
- `textureHeight`: full texture height in pixels

**Returns:** added image

**Since:** 1.2.7

### addImage {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addImage-int-int-int-int-int-String-int-int-int-int-int-int-}

```js
addImage(int x, int y, int width, int height, int zIndex, String id, int imageX, int imageY, int regionWidth, int regionHeight, int textureWidth, int textureHeight): Image
```

Adds an unrotated texture region as an image with a specified z-index and white tint.

**Parameters:**
- `x`: image's screen-space left edge
- `y`: image's screen-space top edge
- `width`: displayed width in screen pixels
- `height`: displayed height in screen pixels
- `zIndex`: ordering against elements on this overlay; lower values draw first
- `id`: texture identifier
- `imageX`: region's left coordinate in the texture
- `imageY`: region's top coordinate in the texture
- `regionWidth`: region width in texture pixels
- `regionHeight`: region height in texture pixels
- `textureWidth`: full texture width in pixels
- `textureHeight`: full texture height in pixels

**Returns:** added image

**Since:** 1.4.0

### addImage {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addImage-int-int-int-int-String-int-int-int-int-int-int-double-}

```js
addImage(int x, int y, int width, int height, String id, int imageX, int imageY, int regionWidth, int regionHeight, int textureWidth, int textureHeight, double rotation): Image
```

Adds a rotated texture region as an image with the default z-index and white tint.  
 Rotation is in degrees about the image's center.

**Parameters:**
- `x`: image's screen-space left edge
- `y`: image's screen-space top edge
- `width`: displayed width in screen pixels
- `height`: displayed height in screen pixels
- `id`: texture identifier
- `imageX`: region's left coordinate in the texture
- `imageY`: region's top coordinate in the texture
- `regionWidth`: region width in texture pixels
- `regionHeight`: region height in texture pixels
- `textureWidth`: full texture width in pixels
- `textureHeight`: full texture height in pixels
- `rotation`: rotation in degrees

**Returns:** added image

**Since:** 1.2.7

### addImage {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addImage-int-int-int-int-int-String-int-int-int-int-int-int-double-}

```js
addImage(int x, int y, int width, int height, int zIndex, String id, int imageX, int imageY, int regionWidth, int regionHeight, int textureWidth, int textureHeight, double rotation): Image
```

Adds a rotated texture region as an image with a specified z-index and white tint.  
 Rotation is in degrees about the image's center.

**Parameters:**
- `x`: image's screen-space left edge
- `y`: image's screen-space top edge
- `width`: displayed width in screen pixels
- `height`: displayed height in screen pixels
- `zIndex`: ordering against elements on this overlay; lower values draw first
- `id`: texture identifier
- `imageX`: region's left coordinate in the texture
- `imageY`: region's top coordinate in the texture
- `regionWidth`: region width in texture pixels
- `regionHeight`: region height in texture pixels
- `textureWidth`: full texture width in pixels
- `textureHeight`: full texture height in pixels
- `rotation`: rotation in degrees

**Returns:** added image

**Since:** 1.4.0

### addImage {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addImage-int-int-int-int-int-int-String-int-int-int-int-int-int-double-}

```js
addImage(int x, int y, int width, int height, int zIndex, int color, String id, int imageX, int imageY, int regionWidth, int regionHeight, int textureWidth, int textureHeight, double rotation): Image
```

Adds a rotated, tinted texture region as an image; its alpha is included in `color`.  
 Rotation is in degrees about the image's center.

**Parameters:**
- `x`: image's screen-space left edge
- `y`: image's screen-space top edge
- `width`: displayed width in screen pixels
- `height`: displayed height in screen pixels
- `zIndex`: ordering against elements on this overlay; lower values draw first
- `color`: tint, packed with alpha in the top byte
- `id`: texture identifier
- `imageX`: region's left coordinate in the texture
- `imageY`: region's top coordinate in the texture
- `regionWidth`: region width in texture pixels
- `regionHeight`: region height in texture pixels
- `textureWidth`: full texture width in pixels
- `textureHeight`: full texture height in pixels
- `rotation`: rotation in degrees

**Returns:** added image

**Since:** 1.6.5

### addImage {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addImage-int-int-int-int-int-int-int-String-int-int-int-int-int-int-double-}

```js
addImage(int x, int y, int width, int height, int zIndex, int alpha, int color, String id, int imageX, int imageY, int regionWidth, int regionHeight, int textureWidth, int textureHeight, double rotation): Image
```

Adds a rotated, tinted texture region as an image, with alpha supplied separately
 from the tint. Rotation is in degrees about the image's center.

**Parameters:**
- `x`: image's screen-space left edge
- `y`: image's screen-space top edge
- `width`: displayed width in screen pixels
- `height`: displayed height in screen pixels
- `zIndex`: ordering against elements on this overlay; lower values draw first
- `alpha`: image alpha, used as the top byte of the packed color
- `color`: tint, whose top byte is replaced by `alpha`
- `id`: texture identifier
- `imageX`: region's left coordinate in the texture
- `imageY`: region's top coordinate in the texture
- `regionWidth`: region width in texture pixels
- `regionHeight`: region height in texture pixels
- `textureWidth`: full texture width in pixels
- `textureHeight`: full texture height in pixels
- `rotation`: rotation in degrees

**Returns:** added image

**Since:** 1.6.5

### addItem {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addItem-int-int-String-}

```js
addItem(int x, int y, String id): Item
```

Adds an item icon with the default overlay enabled.

**Parameters:**
- `x`: left coordinate
- `y`: top coordinate
- `id`: item identifier

**Returns:** the added item element

**Since:** 1.2.7

### addItem {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addItem-int-int-int-String-}

```js
addItem(int x, int y, int zIndex, String id): Item
```

Adds an item icon with the default overlay enabled and the specified draw order.

**Parameters:**
- `x`: left coordinate
- `y`: top coordinate
- `zIndex`: draw order
- `id`: item identifier

**Returns:** the added item element

**Since:** 1.4.0

### addItem {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addItem-int-int-String-boolean-}

```js
addItem(int x, int y, String id, boolean overlay): Item
```

Adds an item icon and controls whether its game-provided decorations are drawn.

**Parameters:**
- `x`: left coordinate
- `y`: top coordinate
- `id`: item identifier
- `overlay`: whether to draw item decorations, including durability and count

**Returns:** the added item element

**Since:** 1.2.7

### addItem {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addItem-int-int-int-String-boolean-}

```js
addItem(int x, int y, int zIndex, String id, boolean overlay): Item
```

Adds an item icon with a draw order and controls whether its game-provided decorations are drawn.

**Parameters:**
- `x`: left coordinate
- `y`: top coordinate
- `zIndex`: draw order
- `id`: item identifier
- `overlay`: whether to draw item decorations, including durability and count

**Returns:** the added item element

**Since:** 1.4.0

### addItem {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addItem-int-int-String-boolean-double-double-}

```js
addItem(int x, int y, String id, boolean overlay, double scale, double rotation): Item
```

Adds a scaled and rotated item icon; rotation is in degrees about its center.

**Parameters:**
- `x`: left coordinate
- `y`: top coordinate
- `id`: item identifier
- `overlay`: whether to draw item decorations
- `scale`: size multiplier
- `rotation`: rotation in degrees

**Returns:** the added item element

**Since:** 1.2.7

### addItem {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addItem-int-int-int-String-boolean-double-double-}

```js
addItem(int x, int y, int zIndex, String id, boolean overlay, double scale, double rotation): Item
```

Adds a scaled and rotated item icon with the specified draw order; rotation is in degrees about its center.

**Parameters:**
- `x`: left coordinate
- `y`: top coordinate
- `zIndex`: draw order
- `id`: item identifier
- `overlay`: whether to draw item decorations
- `scale`: size multiplier
- `rotation`: rotation in degrees

**Returns:** the added item element

**Since:** 1.4.0

### addItem {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addItem-int-int-ItemStackHelper-}

```js
addItem(int x, int y, ItemStackHelper item): Item
```

Adds an item icon from a stack, with the default overlay enabled.

**Parameters:**
- `x`: left coordinate
- `y`: top coordinate
- `item`: item stack helper

**Returns:** the added item element

**Since:** 1.2.7

### addItem {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addItem-int-int-int-ItemStackHelper-}

```js
addItem(int x, int y, int zIndex, ItemStackHelper item): Item
```

Adds an item icon from a stack, with the default overlay and specified draw order.

**Parameters:**
- `x`: left coordinate
- `y`: top coordinate
- `zIndex`: draw order
- `item`: item stack helper

**Returns:** the added item element

**Since:** 1.4.0

### addItem {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addItem-int-int-ItemStackHelper-boolean-}

```js
addItem(int x, int y, ItemStackHelper item, boolean overlay): Item
```

Adds an item icon from a stack and controls whether its game-provided decorations are drawn.

**Parameters:**
- `x`: left coordinate
- `y`: top coordinate
- `item`: item stack helper
- `overlay`: whether to draw item decorations, including durability and count

**Returns:** the added item element

**Since:** 1.2.7

### addItem {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addItem-int-int-int-ItemStackHelper-boolean-}

```js
addItem(int x, int y, int zIndex, ItemStackHelper item, boolean overlay): Item
```

Adds an item icon from a stack with a draw order and control over its decorations.

**Parameters:**
- `x`: left coordinate
- `y`: top coordinate
- `zIndex`: draw order
- `item`: item stack helper
- `overlay`: whether to draw item decorations, including durability and count

**Returns:** the added item element

**Since:** 1.4.0

### addItem {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addItem-int-int-ItemStackHelper-boolean-double-double-}

```js
addItem(int x, int y, ItemStackHelper item, boolean overlay, double scale, double rotation): Item
```

Adds a scaled and rotated item icon from a stack; rotation is in degrees about its center.

**Parameters:**
- `x`: left coordinate
- `y`: top coordinate
- `item`: item stack helper
- `overlay`: whether to draw item decorations
- `scale`: size multiplier
- `rotation`: rotation in degrees

**Returns:** the added item element

**Since:** 1.2.7

### addItem {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addItem-int-int-int-ItemStackHelper-boolean-double-double-}

```js
addItem(int x, int y, int zIndex, ItemStackHelper item, boolean overlay, double scale, double rotation): Item
```

Adds a scaled and rotated item icon from a stack with the specified draw order among this overlay's elements; rotation is in degrees about its center.

**Parameters:**
- `x`: left coordinate
- `y`: top coordinate
- `zIndex`: draw order
- `item`: item stack helper
- `overlay`: whether to draw item decorations
- `scale`: size multiplier
- `rotation`: rotation in degrees

**Returns:** the added item element

**Since:** 1.4.0

### addLine {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addLine-int-int-int-int-int-}

```js
addLine(int x1, int y1, int x2, int y2, int color): Line
```

Adds a one-pixel-wide line between its endpoints, at z-index 0.

**Parameters:**
- `x1`: start x coordinate
- `y1`: start y coordinate
- `x2`: end x coordinate
- `y2`: end y coordinate
- `color`: line color, including alpha

**Returns:** the added line

**Since:** 1.8.4

### addLine {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addLine-int-int-int-int-int-int-}

```js
addLine(int x1, int y1, int x2, int y2, int color, int zIndex): Line
```

Adds a one-pixel-wide line between its endpoints. Lower z-index elements draw first.

**Parameters:**
- `x1`: start x coordinate
- `y1`: start y coordinate
- `x2`: end x coordinate
- `y2`: end y coordinate
- `color`: line color, including alpha
- `zIndex`: draw order relative to other overlay elements

**Returns:** the added line

**Since:** 1.8.4

### addLine {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addLine-int-int-int-int-int-double-}

```js
addLine(int x1, int y1, int x2, int y2, int color, double width): Line
```

Adds a line with the specified width, at z-index 0.

**Parameters:**
- `x1`: start x coordinate
- `y1`: start y coordinate
- `x2`: end x coordinate
- `y2`: end y coordinate
- `color`: line color, including alpha
- `width`: line width in screen pixels

**Returns:** the added line

**Since:** 1.8.4

### addLine {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addLine-int-int-int-int-int-int-double-}

```js
addLine(int x1, int y1, int x2, int y2, int color, int zIndex, double width): Line
```

Adds a line with the specified z-index and width. Lower z-index elements draw first.

**Parameters:**
- `x1`: start x coordinate
- `y1`: start y coordinate
- `x2`: end x coordinate
- `y2`: end y coordinate
- `color`: line color, including alpha
- `zIndex`: draw order relative to other overlay elements
- `width`: line width in screen pixels

**Returns:** the added line

**Since:** 1.8.4

### addLine {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addLine-int-int-int-int-int-double-double-}

```js
addLine(int x1, int y1, int x2, int y2, int color, double width, double rotation): Line
```

Adds a line with the specified width and rotation about its midpoint, at z-index 0.

**Parameters:**
- `x1`: start x coordinate
- `y1`: start y coordinate
- `x2`: end x coordinate
- `y2`: end y coordinate
- `color`: line color, including alpha
- `width`: line width in screen pixels
- `rotation`: rotation in degrees

**Returns:** the added line

**Since:** 1.8.4

### addLine {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addLine-int-int-int-int-int-int-double-double-}

```js
addLine(int x1, int y1, int x2, int y2, int color, int zIndex, double width, double rotation): Line
```

Adds a line with the specified z-index, width, and rotation about its midpoint.  
 Lower z-index elements draw first.

**Parameters:**
- `x1`: start x coordinate
- `y1`: start y coordinate
- `x2`: end x coordinate
- `y2`: end y coordinate
- `color`: line color, including alpha
- `zIndex`: draw order relative to other overlay elements
- `width`: line width in screen pixels
- `rotation`: rotation in degrees

**Returns:** the added line

**Since:** 1.8.4

### addRect {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addRect-int-int-int-int-int-}

```js
addRect(int x1, int y1, int x2, int y2, int color): Rect
```

Adds a filled rectangle between two corners, using the packed color's alpha.

**Parameters:**
- `x1`: first corner's x coordinate
- `y1`: first corner's y coordinate
- `x2`: opposite corner's x coordinate
- `y2`: opposite corner's y coordinate
- `color`: packed color; alpha is in the top byte

**Returns:** added rect

**Since:** 1.2.7

### addRect {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addRect-int-int-int-int-int-int-}

```js
addRect(int x1, int y1, int x2, int y2, int color, int alpha): Rect
```

Adds a filled rectangle between two corners, with alpha supplied separately.

**Parameters:**
- `x1`: first corner's x coordinate
- `y1`: first corner's y coordinate
- `x2`: opposite corner's x coordinate
- `y2`: opposite corner's y coordinate
- `color`: packed color; its top byte is replaced by `alpha`
- `alpha`: alpha value used as the packed color's top byte

**Returns:** added rect

**Since:** 1.2.7

### addRect {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addRect-int-int-int-int-int-int-double-}

```js
addRect(int x1, int y1, int x2, int y2, int color, int alpha, double rotation): Rect
```

Adds a rectangle between two corners; in this overload, rotation is ignored.

**Parameters:**
- `x1`: first corner's x coordinate
- `y1`: first corner's y coordinate
- `x2`: opposite corner's x coordinate
- `y2`: opposite corner's y coordinate
- `color`: rectangle color
- `alpha`: alpha value from 0 (transparent) to 255 (opaque)
- `rotation`: ignored

**Returns:** the added rectangle

**Since:** 1.2.7

### addRect {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addRect-int-int-int-int-int-int-double-int-}

```js
addRect(int x1, int y1, int x2, int y2, int color, int alpha, double rotation, int zIndex): Rect
```

Adds a rectangle between two corners; in this overload, rotation is ignored.

**Parameters:**
- `x1`: first corner's x coordinate
- `y1`: first corner's y coordinate
- `x2`: opposite corner's x coordinate
- `y2`: opposite corner's y coordinate
- `color`: rectangle color
- `alpha`: alpha value from 0 (transparent) to 255 (opaque)
- `rotation`: ignored
- `zIndex`: draw order relative to other overlay elements; lower values draw first

**Returns:** the added rectangle

**Since:** 1.4.0

### addText {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addText-String-int-int-int-boolean-}

```js
addText(String text, int x, int y, int color, boolean shadow): Text
```

Adds text at a position, with a color and optional shadow.  
 
 Coordinates are screen pixels from the top left; `color` is packed with
 alpha in its top byte. This overload uses z-index 0, scale 1, and no rotation.

**Parameters:**
- `text`: the text to display
- `x`: screen x
- `y`: screen y
- `color`: text color
- `shadow`: include shadow layer

**Returns:** added text

**Since:** 1.2.7

### addText {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addText-String-int-int-int-int-boolean-}

```js
addText(String text, int x, int y, int color, int zIndex, boolean shadow): Text
```

Adds text at a position with a color and optional shadow. Coordinates are screen
 pixels from the top left; `color` is packed with alpha in its top byte.  
 Although this overload accepts `zIndex`, it currently uses z-index 0.  
 Scale is 1 and rotation is 0.

**Parameters:**
- `text`: the text to display
- `x`: screen x
- `y`: screen y
- `color`: text color
- `zIndex`: currently ignored; the added text uses z-index 0
- `shadow`: include shadow layer

**Returns:** added text

**Since:** 1.4.0

### addText {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addText-String-int-int-int-boolean-double-double-}

```js
addText(String text, int x, int y, int color, boolean shadow, double scale, double rotation): Text
```

Adds text at a position, with a color, optional shadow, scale, and rotation.  
 Coordinates are screen pixels from the top left; `color` is packed with
 alpha in its top byte. This overload uses z-index 0.

**Parameters:**
- `text`: the text to display
- `x`: screen x
- `y`: screen y
- `color`: text color
- `shadow`: include shadow layer
- `scale`: text scale (as double)
- `rotation`: text rotation (as degrees)

**Returns:** added text

**Since:** 1.2.7

### addText {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addText-String-int-int-int-int-boolean-double-double-}

```js
addText(String text, int x, int y, int color, int zIndex, boolean shadow, double scale, double rotation): Text
```

Adds text at a position, with a color, optional shadow, scale, and rotation,  
 at the specified z-index. Coordinates are screen pixels from the top left;  
 `color` is packed with alpha in its top byte.

**Parameters:**
- `text`: the text to display
- `x`: screen x
- `y`: screen y
- `color`: text color
- `zIndex`: z-index
- `shadow`: include shadow layer
- `scale`: text scale (as double)
- `rotation`: text rotation (as degrees)

**Returns:** added text

**Since:** 1.4.0

### addText {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addText-TextHelper-int-int-int-boolean-}

```js
addText(TextHelper text, int x, int y, int color, boolean shadow): Text
```

Adds styled text at a position, with a color and optional shadow.  
 Coordinates are screen pixels from the top left; `color` is packed
 with alpha in its top byte. This overload uses z-index 0, scale 1, and no rotation.

**Parameters:**
- `text`: the styled text to display
- `x`: screen x
- `y`: screen y
- `color`: text color
- `shadow`: include shadow layer

**Returns:** added text

**Since:** 1.2.7

### addText {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addText-TextHelper-int-int-int-int-boolean-}

```js
addText(TextHelper text, int x, int y, int color, int zIndex, boolean shadow): Text
```

Adds styled text from a [TextHelper](../../helper/TextHelper.md); `color` tints its existing
 styling. Coordinates are screen pixels from the top left. Scale is 1 and
 rotation is 0. The supplied z-index is applied.

**Parameters:**
- `text`: the styled text to display
- `x`: screen x
- `y`: screen y
- `color`: tint applied to the text's existing styling
- `zIndex`: z-index
- `shadow`: include shadow layer

**Returns:** added text

**Since:** 1.4.0

### addText {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addText-TextHelper-int-int-int-boolean-double-double-}

```js
addText(TextHelper text, int x, int y, int color, boolean shadow, double scale, double rotation): Text
```

Adds styled text at a position, with a color, optional shadow, scale, and rotation.  
 Coordinates are screen pixels from the top left; `color` is packed with
 alpha in its top byte. This overload uses z-index 0.

**Parameters:**
- `text`: the styled text to display
- `x`: screen x
- `y`: screen y
- `color`: text color
- `shadow`: include shadow layer
- `scale`: text scale (as double)
- `rotation`: text rotation (as degrees)

**Returns:** added text

**Since:** 1.2.7

### addText {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_addText-TextHelper-int-int-int-int-boolean-double-double-}

```js
addText(TextHelper text, int x, int y, int color, int zIndex, boolean shadow, double scale, double rotation): Text
```

Adds styled text at a position, with a color, optional shadow, scale, and rotation,  
 at the specified z-index. Coordinates are screen pixels from the top left;  
 `color` is packed with alpha in its top byte.

**Parameters:**
- `text`: the styled text to display
- `x`: screen x
- `y`: screen y
- `color`: text color
- `zIndex`: z-index
- `shadow`: include shadow layer
- `scale`: text scale (as double)
- `rotation`: text rotation (as degrees)

**Returns:** added text

**Since:** 1.4.0

### clear {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_clear-}

```js
clear(): void
```

Removes all elements from this overlay without unregistering it or changing its
 other settings. The elements themselves are unaffected and can be added again with
 [reAddElement(RenderElement)](#).

**Since:** 2.1.0

### draw2DBuilder {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_draw2DBuilder-Draw2D-}

```js
draw2DBuilder(Draw2D draw2D): Draw2DElement.Builder
```

Returns a builder for nesting `draw2D` in this overlay. Adding an element
 that would create a cycle is rejected by the overlay.

**Parameters:**
- `draw2D`: the draw2d to add

**Returns:** a builder for a [Draw2D](Draw2D.md).

**Since:** 1.8.4

### getDraw2Ds {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_getDraw2Ds-}

```js
getDraw2Ds(): List<Draw2DElement>
```

Returns a new, mutable list of nested-overlay wrappers in insertion order. Each
 wrapper carries the nested overlay's placement and displayed dimensions; nested
 overlays and their contents are not returned directly.

**Returns:** all registered draw2d elements.

**Since:** 1.8.4

### getElements {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_getElements-}

```js
getElements(): List<RenderElement>
```

Returns an immutable snapshot of all elements in insertion order. It does not
 reflect elements added or removed afterward; the elements themselves are not
 made immutable. Nested overlays appear as wrappers, and their contents are not
 included.

**Returns:** an immutable snapshot of this overlay's elements

**Since:** 1.2.9

### getHeight {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_getHeight-}

```js
getHeight(): int
```

Returns the current height supplied by this overlay, in its element coordinate
 space. Plain overlays default to the window's GUI-scaled height; screens use their
 current screen height, nested overlays their supplied height, and surfaces surface
 pixels.

**Returns:** the supplied height

**Since:** 1.2.7

### getLines {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_getLines-}

```js
getLines(): List<Line>
```

Returns a new, mutable list of this overlay's line elements in insertion order.  
 Nested overlays' contents are not included.

**Returns:** all registered line elements.

**Since:** 1.8.4

### getWidth {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_getWidth-}

```js
getWidth(): int
```

Returns the current width supplied by this overlay, in its element coordinate
 space. Plain overlays default to the window's GUI-scaled width; screens use their
 current screen width, nested overlays their supplied width, and surfaces surface
 pixels. A screen's width can differ from the window's GUI-scaled width.

**Returns:** the supplied width

**Since:** 1.2.7

### getZIndex {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_getZIndex-}

```js
getZIndex(): int
```

Returns this overlay's draw order relative to other registered overlays, not the
 z-index of its elements.

**Returns:** this overlay's draw order

**Since:** 1.8.4

### imageBuilder {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_imageBuilder-}

```js
imageBuilder(): Image.Builder
```

Returns an image builder bound to this overlay. Building does not add an element; an image without a texture draws nothing.

**Returns:** a builder for an [Image](components/Image.md).

**Since:** 1.8.4

### imageBuilder {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_imageBuilder-String-}

```js
imageBuilder(String id): Image.Builder
```

Returns an image builder bound to this overlay with its texture identifier set.

**Parameters:**
- `id`: the id of the image

**Returns:** a builder for an [Image](components/Image.md).

**Since:** 1.8.4

### itemBuilder {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_itemBuilder-}

```js
itemBuilder(): Item.Builder
```

Returns an item builder bound to this overlay; building does not add an element, while `buildAndAdd()` does.

**Returns:** a builder for an [Item](components/Item.md).

**Since:** 1.8.4

### itemBuilder {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_itemBuilder-ItemStackHelper-}

```js
itemBuilder(ItemStackHelper item): Item.Builder
```

Returns an item builder with the supplied stack set, bound to this overlay.

**Parameters:**
- `item`: the item to use

**Returns:** a builder for an [Item](components/Item.md).

**Since:** 1.8.4

### lineBuilder {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_lineBuilder-}

```js
lineBuilder(): Line.Builder
```

Returns a line builder bound to this overlay; `buildAndAdd()` adds the
 built line to it.

**Returns:** a builder for a [Line](components/Line.md).

**Since:** 1.8.4

### lineBuilder {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_lineBuilder-int-int-int-int-}

```js
lineBuilder(int x1, int y1, int x2, int y2): Line.Builder
```

Returns a line builder with both endpoints set.

**Parameters:**
- `x1`: the x position of the first point
- `y1`: the y position of the first point
- `x2`: the x position of the second point
- `y2`: the y position of the second point

**Returns:** a builder for a [Line](components/Line.md).

**Since:** 1.8.4

### reAddElement {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_reAddElement-T-}

```js
reAddElement(T extends RenderElement e): T extends RenderElement
```

Adds an element to this overlay and returns it. This can restore an element removed
 with [removeElement(RenderElement)](#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_removeElement-RenderElement-) or add one built without
 `buildAndAdd()`. For nested-overlay wrappers, returns `null` if the
 wrapped overlay is missing, is this overlay, or would create a cycle.

**Parameters:**
- `e`: the element to put back

**Type Parameters:**
- `T`: the type of element to add

**Returns:** the element, or `null` if it is a nested overlay that was refused

**Since:** 1.2.9

### rectBuilder {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_rectBuilder-}

```js
rectBuilder(): Rect.Builder
```

Returns a rectangle builder bound to this overlay; `buildAndAdd()` adds
 the built rectangle to it.

**Returns:** a builder for a [Rect](components/Rect.md).

**Since:** 1.8.4

### rectBuilder {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_rectBuilder-int-int-int-int-}

```js
rectBuilder(int x, int y, int width, int height): Rect.Builder
```

Returns a rectangle builder with its first corner and size set.

**Parameters:**
- `x`: the x position of the rectangle
- `y`: the y position of the rectangle
- `width`: the width of the rectangle
- `height`: the height of the rectangle

**Returns:** a builder for a [Rect](components/Rect.md).

**Since:** 1.8.4

### removeDraw2D {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_removeDraw2D-Draw2DElement-}

```js
removeDraw2D(Draw2DElement draw2D): T
```

Removes the nested-overlay wrapper from this overlay without changing the nested overlay.

**Parameters:**
- `draw2D`: the wrapper to remove

**Returns:** this overlay for chaining

**Since:** 1.8.4

### removeElement {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_removeElement-RenderElement-}

```js
removeElement(RenderElement e): T
```

Removes an element of any type from this overlay. If absent, it has no effect;  
 the element itself is unchanged and can be added again with
 [reAddElement(RenderElement)](#). The deprecated typed removals do the same.

**Parameters:**
- `e`: the element to take off

**Returns:** self for chaining

**Since:** 1.2.9

### removeLine {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_removeLine-Line-}

```js
removeLine(Line l): T
```

Removes the line from this overlay without modifying it. It can be added
 again with [reAddElement(RenderElement)](#).

**Parameters:**
- `l`: the line to remove

**Returns:** this overlay for chaining

**Since:** 1.8.4

### setOnFailInit {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_setOnFailInit-MethodWrapper-}

```js
setOnFailInit(MethodWrapper<String, Object, Object, ?> catchInit): T
```

Sets the callback that receives an initialization failure's `toString()`
 value. If unset, the failure is logged. This handles initialization failures
 only.

**Parameters:**
- `catchInit`: calls your method as a [Consumer](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/function/Consumer.html)&lt;[String](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/String.html)&gt;

**Returns:** self for chaining

**Since:** 1.2.7

### setOnInit {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_setOnInit-MethodWrapper-}

```js
setOnInit(MethodWrapper<T, Object, Object, ?> onInit): T
```

Sets the callback run when this overlay initializes. If a callback is set, its
 elements are cleared first; nested overlays are initialized afterward. Callback
 failures are passed to the fail callback or logged.

**Parameters:**
- `onInit`: calls your method as a [Consumer](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/function/Consumer.html)&lt;T&gt;

**Returns:** self for chaining

**Since:** 1.2.7

### setZIndex {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_setZIndex-int-}

```js
setZIndex(int zIndex): void
```

Sets this overlay's draw order relative to other registered overlays; lower values
 draw first. This orders whole overlays, not their elements, and does not affect
 screen overlays.

**Parameters:**
- `zIndex`: the overlay's draw order

**Since:** 1.8.4

### textBuilder {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_textBuilder-}

```js
textBuilder(): Text.Builder
```

Returns a text builder bound to this overlay; `buildAndAdd()` adds the
 built text to it.

**Returns:** a builder for a [Text](components/Text.md).

**Since:** 1.8.4

### textBuilder {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_textBuilder-String-}

```js
textBuilder(String text): Text.Builder
```

Returns a text builder with its text set.

**Parameters:**
- `text`: the text to display

**Returns:** a builder for a [Text](components/Text.md).

**Since:** 1.8.4

### textBuilder {#com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D_textBuilder-TextHelper-}

```js
textBuilder(TextHelper text): Text.Builder
```

Returns a text builder initialized with the supplied styled text.

**Parameters:**
- `text`: the text to display

**Returns:** a builder for a [Text](components/Text.md).

**Since:** 1.8.4
