Line
com.jsmacrosce.jsmacros.client.api.classes.render.components.Line
A line is defined by two endpoints, a stroke thickness, and a rotation. The endpoint differences determine its scaled width and height; width is the stroke thickness. Nonpositive or non-finite thickness is not rendered. Positive fractional thickness and length are drawn as stored rather than rounded,
although the renderer raises thickness to at least one physical pixel and does not antialias the strip's edges. Rotation is about the first endpoint by default, or the midpoint when rotateCenter is true. Constructors and setRotation(double) normalize finite angles to [-180, 180).
const draw = Hud.createDraw2D();
const line = draw.addLine(0, 0, 50, 50, Color.rgb(0xFF, 0xFF, 0xFF), 0, 2);
draw.register();
Chat.log(`${line.getWidth()} thick, reaching ${line.getScaledWidth()} across`);Available in scripts as RenderElements.Line.
Nested types
Constructors
new Line
new Line(int x1, int y1, int x2, int y2, int color, float rotation, float width, int zIndex)#[-180, 180). The color is processed by setColor(int); a zero-alpha color becomes opaque except for pure black.Parameters:
x1: the x position of the start of the liney1: the y position of the start of the linex2: the x position of the end of the liney2: the y position of the end of the linecolor: the color, with the alpha in the top byterotation: the rotation in degreeswidth: the thickness of the linezIndex: the z-index against the other elements on the overlay
Fields
color
color: int#parent
rotateCenter
rotateCenter: boolean#false; builder-created lines default to true.rotation
rotation: float#[-180, 180); direct field writes do not.width
width: float#x1
x1: int#x2
x2: int#y1
y1: int#y2
y2: int#zIndex
zIndex: int#Methods
getAlpha
getColor
getParentHeight
getParentHeight(): int#getParentWidth
getParentWidth(): int#getRotation
getScaledHeight
getScaledHeight(): int#getScaledLeft
getScaledLeft(): int#getScaledTop
getScaledTop(): int#getScaledWidth
getScaledWidth(): int#getWidth
getX1
getX2
getY1
getY2
getZIndex
getZIndex(): int#isRotatingCenter
true if this line should be rotated around its center, false otherwise.moveTo
render
render(GuiGraphicsExtractor drawContext, int mouseX, int mouseY, float delta): void#Parameters:
drawContext: the graphics context receiving the stripmouseX: unused mouse x coordinatemouseY: unused mouse y coordinatedelta: unused frame delta
setAlpha
setColor
Parameters:
color: the color of the line
Parameters:
color: the color of the linealpha: the alpha of the line
setParent
setPos
setPos1
setPos2
setRotateCenter
setRotation
rotateCenter is true, otherwise about the first endpoint.Parameters:
rotation: the rotation (clockwise) of the line
setWidth
Parameters:
width: the width of the line