Line.Builder
com.jsmacrosce.jsmacros.client.api.classes.render.components.Line.Builder
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
Methods
alpha
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
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.
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 linealpha: the alpha component of the color
Returns: self for chaining.
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 colorg: the green component of the colorb: the blue component of the color
Returns: self for chaining.
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 colorg: the green component of the colorb: the blue component of the colora: the alpha value of the color
Returns: self for chaining.
getAlpha
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
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
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
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
Returns the x coordinate of the first endpoint.
Returns: the x position of the first point.
getX2
Returns the x coordinate of the builder's second endpoint (zero by default).
Returns: the x position of the second point.
getY1
Returns the y coordinate of the first endpoint.
Returns: the y position of the first point.
getY2
Returns the y coordinate of the builder's second endpoint (zero by default).
Returns: the y position of the second point.
getZIndex
Returns the draw-order value that will be assigned to the built line.
Returns: the z-index of the line.
isRotatingCenter
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 positiony: the new y position
Returns: self for chaining.
pos
Sets both endpoints of the line.
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
Returns: self for chaining.
pos1
Sets both coordinates of the first endpoint, leaving the second unchanged.
Parameters:
x1: the x position of the first pointy1: the y position of the first point
Returns: self for chaining.
pos2
Sets both coordinates of the second endpoint, leaving the first unchanged.
Parameters:
x2: the x position of the second pointy2: the y position of the second point
Returns: self for chaining.
rotateCenter
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
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
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
Sets the x coordinate of the first endpoint.
Parameters:
x1: the x position of the first point
Returns: self for chaining.
x2
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
Sets the y coordinate of the first endpoint.
Parameters:
y1: the y position of the first point
Returns: self for chaining.
y2
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
Sets this builder's draw-order value; lower values are drawn first.
Parameters:
zIndex: the z-index of the line
Returns: self for chaining.