Skip to content

Draw2D Class

wagyourtail edited this page Sep 20, 2020 · 13 revisions

The Draw2D Class, methods are as follows:

this is OverlayHud in 1.0.5

Draw2D() 1.0.5+

Example: new Draw2D()

Initialize, to call this it is easiest to refer to Hud.

onInit 1.0.5+

put a js function here for initializing elements. Example:

hud.onInit = (hud_obj) => {
    let rgb = 0xFFFFFF;
    hud_obj.addText("hello, world!", 0, 0, rgb, true);
}

getWidth() 1.0.5+

Example: overlay.getWidth()

returns the internal width of the window.

getHeight() 1.0.5+

Example: overlay.getHeight()

returns the internal height of the window.

getTexts() 1.0.5+

Example: overlay.getTexts()

returns an ArrayList of RenderCommon$text elements.

getRects() 1.0.5+

Example: overlay.getRects()

returns an ArrayList of RenderCommon$rect elements.

getItems() 1.0.5+

Example: overlay.getItems()

returns an ArrayList of RenderCommon$item elements.

getImages() 1.2.3+

Example: overlay.getImages()

returns an ArrayList of RenderCommon$image elements.

addText(String, Int, Int, Int, Bool, [double, float]) 1.0.5+

Example: overlay.addText("Text", x, y, rgbHex, shadow, scale, rotation)

  • scale/rotation optionals were added in 1.2.6+

returns the RenderCommon$text object.

removeText(RenderCommon$text) 1.0.5+

Example: overlay.removeText(t)

removes a RenderCommon$text element from the screen.

addRect(Int, Int, Int, Int, Int, [int, [float]]) 1.0.5+

Example: overlay.addRect(x1, y1, x2, y2, argbHex, alpha, rotation)

  • alpha was added in version 1.1.8+
    • alpha is optional and can just be in the argbHex field.
  • rotation was added in version 1.2.6+
    • alpha is required to use rotation.

returns the RenderCommon$rect object.

removeRect(RenderCommon$rect) 1.0.5+

Example: overlay.removeRect(r)

removes a RenderCommon$rect element from the screen.

addImage(int, int, int, int, string, int, int, int, int, int, int, [float]) 1.2.3+

Example: overlay.addImage(x, y, width, height, id, imageX, imageY, regionWidth, regionHeight, textureWidth, textureHeight, rotation)

  • rotation was added in 1.2.6+

returns the RenderCommon$image object.

removeImage(RenderCommon$image) 1.2.3+

Example: overlay.removeImage(image)

remove a RenderCommon$image element from the screen.

addItem(Int, Int, ItemStackHelper, boolean, [double, float]) 1.0.5+

Example: overlay.addItem(x, y, item, showOverlay, scale, rotation)

  • showOverlay added in 1.2.0+
  • scale/rotation optionals were added in 1.2.6+

returns the RenderCommon$item object.

addItem(Int, Int, String, boolean, [double, float]) 1.0.5+

Example: overlay.addItem(x, y, itemid, showOverlay, scale, rotation)

  • showOverlay added in 1.2.0+
  • scale/rotation optionals were added in 1.2.6+

returns the RenderCommon$item object.

removeItem(RenderCommon$item) 1.0.5+

Example: overlay.removeItem(i)

removes an RenderCommon$item element from the screen.

Clone this wiki locally