Skip to content

Line.Builder ​

com.jsmacrosce.jsmacros.client.api.classes.render.components.Line.Builder

Since1.8.4

Builder for configuring and creating a line on an overlay. The four endpoint coordinates default to zero, width to one, rotation to zero, and color to opaque white; builder-created lines rotate around their center by default.

Nested type declared in Line.

Constructors ​

new Line.Builder ​

new Line.Builder(IDraw2D<?> draw2D)#
Creates a builder associated with the given overlay.

Parameters:

  • draw2D: the overlay the lines will be added to

Methods ​

alpha ​

alpha(int alpha): Line.BuilderSince1.8.4#
Sets the separate alpha without changing the stored color. The value is not clamped; when building, its low eight bits become the line's alpha byte.

Parameters:

  • alpha: the alpha value of the color
Returns: self for chaining.

color ​

color(int color): Line.BuilderSince1.8.4#
Sets the packed color and derives the builder's separate alpha from the value after applying the renderer's zero-alpha rule. A later alpha call changes the separate alpha without changing this packed color.

Parameters:

  • color: the color of the line
Returns: self for chaining.
color(int color, int alpha): Line.BuilderSince1.8.4#
Sets the packed color and separate alpha without fix-up. The builder uses the separate alpha as the built line's top byte, so this overload can retain an alpha of zero.

Parameters:

  • color: the color of the line
  • alpha: the alpha component of the color
Returns: self for chaining.
color(int r, int g, int b): Line.BuilderSince1.8.4#
Packs the components into the color's low 24 bits without changing the separate alpha. Components are shifted and combined as supplied, without range validation; the built line takes its top byte from the separate alpha.

Parameters:

  • r: the red component of the color
  • g: the green component of the color
  • b: the blue component of the color
Returns: self for chaining.
color(int r, int g, int b, int a): Line.BuilderSince1.8.4#
Packs all four components into the stored color without range validation. This does not change the builder's separate alpha: when built, the line uses that separate value for its top byte, so use alpha to set transparency.

Parameters:

  • r: the red component of the color
  • g: the green component of the color
  • b: the blue component of the color
  • a: the alpha value of the color
Returns: self for chaining.

getAlpha ​

getAlpha(): intSince1.8.4#
Returns the separate alpha used for the built line's top byte. It defaults to opaque and is independent of the alpha packed by the four-component color overload.
Returns: the alpha value of the color.

getColor ​

getColor(): intSince1.8.4#
Returns the stored packed color. Its value depends on the setter used; when building, the separate alpha replaces the stored color's top byte.
Returns: the color of the line.

getParentHeight ​

getParentHeight(): int#
Returns the height of the overlay associated with this builder.
Returns: the height of the parent

getParentWidth ​

getParentWidth(): int#
Returns the width of the overlay associated with this builder.
Returns: the width of the parent

getRotation ​

getRotation(): floatSince1.8.4#
Returns the stored rotation in degrees (zero by default); the built line normalizes finite angles.
Returns: the rotation (clockwise) of the line.

getScaledHeight ​

getScaledHeight(): int#
Returns the absolute difference between the endpoints' y coordinates; this is the line's vertical extent, not its stroke thickness.
Returns: the scaled height

getScaledLeft ​

getScaledLeft(): int#
Returns the smaller x coordinate of the two endpoints.
Returns: the position of the scaled element's left side

getScaledTop ​

getScaledTop(): int#
Returns the smaller y coordinate of the two endpoints.
Returns: the position of the scaled element's top side

getScaledWidth ​

getScaledWidth(): int#
Returns the absolute difference between the endpoints' x coordinates; this is the line's horizontal extent, not its stroke thickness.
Returns: the scaled width

getWidth ​

getWidth(): floatSince1.8.4#
Returns the configured stroke thickness in screen pixels; this is distinct from the endpoint-to-endpoint extent returned by getScaledWidth().
Returns: the width of the line.

getX1 ​

getX1(): intSince1.8.4#
Returns the x coordinate of the first endpoint.
Returns: the x position of the first point.

getX2 ​

getX2(): intSince1.8.4#
Returns the x coordinate of the builder's second endpoint (zero by default).
Returns: the x position of the second point.

getY1 ​

getY1(): intSince1.8.4#
Returns the y coordinate of the first endpoint.
Returns: the y position of the first point.

getY2 ​

getY2(): intSince1.8.4#
Returns the y coordinate of the builder's second endpoint (zero by default).
Returns: the y position of the second point.

getZIndex ​

getZIndex(): intSince1.8.4#
Returns the draw-order value that will be assigned to the built line.
Returns: the z-index of the line.

isRotatingCenter ​

isRotatingCenter(): booleanSince1.8.4#
Returns whether lines built by this builder rotate about their midpoint. Builder-created lines use midpoint rotation by default.
Returns: true if this line should be rotated around its center, false otherwise.

moveTo ​

moveTo(int x, int y): Line.Builder#
Translates both endpoints so their minimum x and y coordinates match the requested position, preserving their relative positions.

Parameters:

  • x: the new x position
  • y: the new y position
Returns: self for chaining.

pos ​

pos(int x1, int y1, int x2, int y2): Line.BuilderSince1.8.4#
Sets both endpoints of the line.

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: self for chaining.

pos1 ​

pos1(int x1, int y1): Line.BuilderSince1.8.4#
Sets both coordinates of the first endpoint, leaving the second unchanged.

Parameters:

  • x1: the x position of the first point
  • y1: the y position of the first point
Returns: self for chaining.

pos2 ​

pos2(int x2, int y2): Line.BuilderSince1.8.4#
Sets both coordinates of the second endpoint, leaving the first unchanged.

Parameters:

  • x2: the x position of the second point
  • y2: the y position of the second point
Returns: self for chaining.

rotateCenter ​

rotateCenter(boolean rotateCenter): Line.BuilderSince1.8.4#
Selects whether rotation is about the line's center rather than its first endpoint. Builder-created lines default to center rotation.

Parameters:

  • rotateCenter: whether this line should be rotated around its center
Returns: self for chaining.

rotation ​

rotation(double rotation): Line.BuilderSince1.8.4#
Sets the rotation in degrees. The builder stores the supplied value; the built line normalizes finite angles, and rotates about its center by default.

Parameters:

  • rotation: the rotation (clockwise) of the line
Returns: self for chaining.

width ​

width(double width): Line.BuilderSince1.8.4#
Sets the stroke thickness in screen pixels; it does not change the distance between the endpoints. Values, including zero and negative values, are stored as floats without validation.

Parameters:

  • width: the width of the line
Returns: self for chaining.

x1 ​

x1(int x1): Line.BuilderSince1.8.4#
Sets the x coordinate of the first endpoint.

Parameters:

  • x1: the x position of the first point
Returns: self for chaining.

x2 ​

x2(int x2): Line.BuilderSince1.8.4#
Sets the second endpoint's x coordinate without changing other coordinates.

Parameters:

  • x2: the x position of the second point
Returns: self for chaining.

y1 ​

y1(int y1): Line.BuilderSince1.8.4#
Sets the y coordinate of the first endpoint.

Parameters:

  • y1: the y position of the first point
Returns: self for chaining.

y2 ​

y2(int y2): Line.BuilderSince1.8.4#
Sets the second endpoint's y coordinate without changing other coordinates.

Parameters:

  • y2: the y position of the second point
Returns: self for chaining.

zIndex ​

zIndex(int zIndex): Line.BuilderSince1.8.4#
Sets this builder's draw-order value; lower values are drawn first.

Parameters:

  • zIndex: the z-index of the line
Returns: self for chaining.