IDraw2D
com.jsmacrosce.jsmacros.client.api.classes.render.IDraw2D
A 2D overlay that holds render elements; implemented by standalone overlays and screens.
Both implementations expose the same element API.
// 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
null if that would create a cycle.Parameters:
draw2D: the overlay to draw inside this onex: the x position on this draw2dy: the y position on this draw2dwidth: the nested overlay's widthheight: the nested overlay's height
null if nesting would create a cyclenull if that would create a cycle.Parameters:
draw2D: the overlay to draw inside this onex: the x position on this draw2dy: the y position on this draw2dwidth: the nested overlay's widthheight: the nested overlay's heightzIndex: the nested overlay's draw order among this overlay's elements
null if nesting would create a cycleaddImage
addImage(int x, int y, int width, int height, String id, int imageX, int imageY, int regionWidth, int regionHeight, int textureWidth, int textureHeight): ImageSince1.2.7#Parameters:
x: image's screen-space left edgey: image's screen-space top edgewidth: displayed width in screen pixelsheight: displayed height in screen pixelsid: texture identifierimageX: region's left coordinate in the textureimageY: region's top coordinate in the textureregionWidth: region width in texture pixelsregionHeight: region height in texture pixelstextureWidth: full texture width in pixelstextureHeight: full texture height in pixels
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): ImageSince1.4.0#Parameters:
x: image's screen-space left edgey: image's screen-space top edgewidth: displayed width in screen pixelsheight: displayed height in screen pixelszIndex: ordering against elements on this overlay; lower values draw firstid: texture identifierimageX: region's left coordinate in the textureimageY: region's top coordinate in the textureregionWidth: region width in texture pixelsregionHeight: region height in texture pixelstextureWidth: full texture width in pixelstextureHeight: full texture height in pixels
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): ImageSince1.2.7#Parameters:
x: image's screen-space left edgey: image's screen-space top edgewidth: displayed width in screen pixelsheight: displayed height in screen pixelsid: texture identifierimageX: region's left coordinate in the textureimageY: region's top coordinate in the textureregionWidth: region width in texture pixelsregionHeight: region height in texture pixelstextureWidth: full texture width in pixelstextureHeight: full texture height in pixelsrotation: rotation in degrees
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): ImageSince1.4.0#Parameters:
x: image's screen-space left edgey: image's screen-space top edgewidth: displayed width in screen pixelsheight: displayed height in screen pixelszIndex: ordering against elements on this overlay; lower values draw firstid: texture identifierimageX: region's left coordinate in the textureimageY: region's top coordinate in the textureregionWidth: region width in texture pixelsregionHeight: region height in texture pixelstextureWidth: full texture width in pixelstextureHeight: full texture height in pixelsrotation: rotation in degrees
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): ImageSince1.6.5#color. Rotation is in degrees about the image's center.Parameters:
x: image's screen-space left edgey: image's screen-space top edgewidth: displayed width in screen pixelsheight: displayed height in screen pixelszIndex: ordering against elements on this overlay; lower values draw firstcolor: tint, packed with alpha in the top byteid: texture identifierimageX: region's left coordinate in the textureimageY: region's top coordinate in the textureregionWidth: region width in texture pixelsregionHeight: region height in texture pixelstextureWidth: full texture width in pixelstextureHeight: full texture height in pixelsrotation: rotation in degrees
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): ImageSince1.6.5#Parameters:
x: image's screen-space left edgey: image's screen-space top edgewidth: displayed width in screen pixelsheight: displayed height in screen pixelszIndex: ordering against elements on this overlay; lower values draw firstalpha: image alpha, used as the top byte of the packed colorcolor: tint, whose top byte is replaced byalphaid: texture identifierimageX: region's left coordinate in the textureimageY: region's top coordinate in the textureregionWidth: region width in texture pixelsregionHeight: region height in texture pixelstextureWidth: full texture width in pixelstextureHeight: full texture height in pixelsrotation: rotation in degrees
addItem
Parameters:
x: left coordinatey: top coordinateid: item identifier
Parameters:
x: left coordinatey: top coordinatezIndex: draw orderid: item identifier
Parameters:
x: left coordinatey: top coordinateid: item identifieroverlay: whether to draw item decorations, including durability and count
Parameters:
x: left coordinatey: top coordinatezIndex: draw orderid: item identifieroverlay: whether to draw item decorations, including durability and count
Parameters:
x: left coordinatey: top coordinateid: item identifieroverlay: whether to draw item decorationsscale: size multiplierrotation: rotation in degrees
addItem(int x, int y, int zIndex, String id, boolean overlay, double scale, double rotation): ItemSince1.4.0#Parameters:
x: left coordinatey: top coordinatezIndex: draw orderid: item identifieroverlay: whether to draw item decorationsscale: size multiplierrotation: rotation in degrees
Parameters:
x: left coordinatey: top coordinateitem: item stack helper
Parameters:
x: left coordinatey: top coordinatezIndex: draw orderitem: item stack helper
Parameters:
x: left coordinatey: top coordinateitem: item stack helperoverlay: whether to draw item decorations, including durability and count
Parameters:
x: left coordinatey: top coordinatezIndex: draw orderitem: item stack helperoverlay: whether to draw item decorations, including durability and count
addItem(int x, int y, ItemStackHelper item, boolean overlay, double scale, double rotation): ItemSince1.2.7#Parameters:
x: left coordinatey: top coordinateitem: item stack helperoverlay: whether to draw item decorationsscale: size multiplierrotation: rotation in degrees
addItem(int x, int y, int zIndex, ItemStackHelper item, boolean overlay, double scale, double rotation): ItemSince1.4.0#Parameters:
x: left coordinatey: top coordinatezIndex: draw orderitem: item stack helperoverlay: whether to draw item decorationsscale: size multiplierrotation: rotation in degrees
addLine
Parameters:
x1: start x coordinatey1: start y coordinatex2: end x coordinatey2: end y coordinatecolor: line color, including alpha
Parameters:
x1: start x coordinatey1: start y coordinatex2: end x coordinatey2: end y coordinatecolor: line color, including alphazIndex: draw order relative to other overlay elements
Parameters:
x1: start x coordinatey1: start y coordinatex2: end x coordinatey2: end y coordinatecolor: line color, including alphawidth: line width in screen pixels
Parameters:
x1: start x coordinatey1: start y coordinatex2: end x coordinatey2: end y coordinatecolor: line color, including alphazIndex: draw order relative to other overlay elementswidth: line width in screen pixels
Parameters:
x1: start x coordinatey1: start y coordinatex2: end x coordinatey2: end y coordinatecolor: line color, including alphawidth: line width in screen pixelsrotation: rotation in degrees
addLine(int x1, int y1, int x2, int y2, int color, int zIndex, double width, double rotation): LineSince1.8.4#Parameters:
x1: start x coordinatey1: start y coordinatex2: end x coordinatey2: end y coordinatecolor: line color, including alphazIndex: draw order relative to other overlay elementswidth: line width in screen pixelsrotation: rotation in degrees
addRect
Parameters:
x1: first corner's x coordinatey1: first corner's y coordinatex2: opposite corner's x coordinatey2: opposite corner's y coordinatecolor: packed color; alpha is in the top byte
Parameters:
x1: first corner's x coordinatey1: first corner's y coordinatex2: opposite corner's x coordinatey2: opposite corner's y coordinatecolor: packed color; its top byte is replaced byalphaalpha: alpha value used as the packed color's top byte
Parameters:
x1: first corner's x coordinatey1: first corner's y coordinatex2: opposite corner's x coordinatey2: opposite corner's y coordinatecolor: rectangle coloralpha: alpha value from 0 (transparent) to 255 (opaque)rotation: ignored
addRect(int x1, int y1, int x2, int y2, int color, int alpha, double rotation, int zIndex): RectSince1.4.0#Parameters:
x1: first corner's x coordinatey1: first corner's y coordinatex2: opposite corner's x coordinatey2: opposite corner's y coordinatecolor: rectangle coloralpha: alpha value from 0 (transparent) to 255 (opaque)rotation: ignoredzIndex: draw order relative to other overlay elements; lower values draw first
addText
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 displayx: screen xy: screen ycolor: text colorshadow: include shadow layer
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 displayx: screen xy: screen ycolor: text colorzIndex: currently ignored; the added text uses z-index 0shadow: include shadow layer
addText(String text, int x, int y, int color, boolean shadow, double scale, double rotation): TextSince1.2.7#color is packed with alpha in its top byte. This overload uses z-index 0.Parameters:
text: the text to displayx: screen xy: screen ycolor: text colorshadow: include shadow layerscale: text scale (as double)rotation: text rotation (as degrees)
addText(String text, int x, int y, int color, int zIndex, boolean shadow, double scale, double rotation): TextSince1.4.0#color is packed with alpha in its top byte.Parameters:
text: the text to displayx: screen xy: screen ycolor: text colorzIndex: z-indexshadow: include shadow layerscale: text scale (as double)rotation: text rotation (as degrees)
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 displayx: screen xy: screen ycolor: text colorshadow: include shadow layer
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 displayx: screen xy: screen ycolor: tint applied to the text's existing stylingzIndex: z-indexshadow: include shadow layer
addText(TextHelper text, int x, int y, int color, boolean shadow, double scale, double rotation): TextSince1.2.7#color is packed with alpha in its top byte. This overload uses z-index 0.Parameters:
text: the styled text to displayx: screen xy: screen ycolor: text colorshadow: include shadow layerscale: text scale (as double)rotation: text rotation (as degrees)
addText(TextHelper text, int x, int y, int color, int zIndex, boolean shadow, double scale, double rotation): TextSince1.4.0#color is packed with alpha in its top byte.Parameters:
text: the styled text to displayx: screen xy: screen ycolor: text colorzIndex: z-indexshadow: include shadow layerscale: text scale (as double)rotation: text rotation (as degrees)
clear
draw2DBuilder
draw2D in this overlay. Adding an element that would create a cycle is rejected by the overlay.Parameters:
draw2D: the draw2d to add
getDraw2Ds
getElements
getHeight
getLines
getWidth
getZIndex
imageBuilder
Parameters:
id: the id of the image
itemBuilder
buildAndAdd() does.Parameters:
item: the item to use
lineBuilder
buildAndAdd() adds the built line to it.Parameters:
x1: the x position of the first pointy1: the y position of the first pointx2: the x position of the second pointy2: the y position of the second point
reAddElement
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
null if it is a nested overlay that was refusedrectBuilder
buildAndAdd() adds the built rectangle to it.Parameters:
x: the x position of the rectangley: the y position of the rectanglewidth: the width of the rectangleheight: the height of the rectangle
removeDraw2D
Parameters:
draw2D: the wrapper to remove
removeElement
Parameters:
e: the element to take off
removeLine
Parameters:
l: the line to remove
setOnFailInit
setOnInit
Parameters:
onInit: calls your method as a Consumer<T>
setZIndex
Parameters:
zIndex: the overlay's draw order
textBuilder
buildAndAdd() adds the built text to it.Parameters:
text: the text to display
Parameters:
text: the text to display