Rect.Builder
com.jsmacrosce.jsmacros.client.api.classes.render.components.Rect.Builder
Builder for a rectangle on an overlay. Coordinates can be supplied as two corners or as a first corner and a size. Defaults are zero coordinates, opaque white,
zero rotation, and rotation about the center; unlike directly constructed rectangles, builders rotate about the center by default.
Nested type declared in Rect.
Constructors
new Rect.Builder
Methods
alpha
Sets the alpha value independently of the stored color. The value is not clamped; when built, its shifted bits may also affect the color channels.
Parameters:
alpha: the alpha value of the color
Returns: self for chaining.
color
Sets a packed color and stores its fixed-up alpha separately; a later
alpha call replaces that alpha.Parameters:
color: the color of the rectangle
Returns: self for chaining.
Packs the components into the low 24 bits; the separately stored alpha is unchanged. Component values are packed without range validation.
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 the RGB components into the low 24 bits and stores
a separately; component values are packed without range validation.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.
Stores the color and alpha separately, without applying the packed-color overload's alpha fix-up.
Parameters:
color: the color of the rectanglealpha: the alpha value of the color
Returns: self for chaining.
createElement
getAlpha
Returns the separately stored alpha value, initially 255.
Returns: the alpha value of the color.
getColor
Returns the stored color value. Component-based
color overloads store only the low 24 RGB bits; packed-color overloads retain the supplied value.Returns: the color of the rectangle.
getHeight
Returns the absolute distance between the two y coordinates.
Returns: the height of the rectangle.
getParentHeight
getParentHeight(): int#Returns the height of the builder's overlay, used by parent-relative alignment.
Returns: the height of the parent
getParentWidth
getParentWidth(): int#Returns the width of the builder's overlay, used by parent-relative alignment.
Returns: the width of the parent
getRotation
Returns the stored rotation in degrees, without normalization.
Returns: the rotation (clockwise) of the rectangle in degrees.
getScaledHeight
getScaledHeight(): int#Returns the builder's height; rectangles have no additional scale.
Returns: the scaled height
getScaledLeft
getScaledLeft(): int#Returns the smaller of the builder's two x coordinates, regardless of corner order.
Returns: the position of the scaled element's left side
getScaledTop
getScaledTop(): int#Returns the smaller of the builder's two y coordinates, regardless of corner order.
Returns: the position of the scaled element's top side
getScaledWidth
getScaledWidth(): int#Returns the builder's width; rectangles have no additional scale.
Returns: the scaled width
getWidth
Returns the absolute distance between the two x coordinates.
Returns: the width of the rectangle.
getX1
Returns the first x coordinate; it starts at zero.
Returns: the first x position of the rectangle.
getX2
Returns the second x coordinate; size setters calculate it from the first x coordinate.
Returns: the second x position of the rectangle.
getY1
Returns the first y coordinate; it starts at zero.
Returns: the first y position of the rectangle.
getY2
Returns the second y coordinate; size setters calculate it from the first y coordinate.
Returns: the second y position of the rectangle.
getZIndex
Returns the overlay ordering index to be used when building the rectangle.
Returns: the z-index of the rectangle.
height
Sets the second y coordinate to
y1 + height; the value is measured from the first corner, regardless of the existing second corner.Parameters:
height: the height of the rectangle
Returns: self for chaining.
isRotatingCenter
Returns whether the built rectangle rotates around its center.
Returns:
true if this rectangle should be rotated around its center, false otherwise.moveTo
moveTo(int x, int y): Rect.Builder#Moves the builder so
(x, y) is its first corner, preserving its current width and height.Parameters:
x: the new x positiony: the new y position
Returns: self for chaining.
pos
Sets both rectangle corners.
Parameters:
x1: the first x position of the rectangley1: the first y position of the rectanglex2: the second x position of the rectangley2: the second y position of the rectangle
Returns: self for chaining.
pos1
Sets the first corner coordinates.
Parameters:
x1: the first x position of the rectangley1: the first y position of the rectangle
Returns: self for chaining.
pos2
Sets the second corner coordinates.
Parameters:
x2: the second x position of the rectangley2: the second y position of the rectangle
Returns: self for chaining.
rotateCenter
Selects whether rotation is around the rectangle's center; builders default to
true.Parameters:
rotateCenter: whether this rectangle should be rotated around its center
Returns: self for chaining.
rotation
Sets the rotation in degrees; the builder stores the supplied value as a
float without normalizing it.Parameters:
rotation: the rotation (clockwise) of the rectangle in degrees
Returns: self for chaining.
size
Sets the rectangle's width and height, measured from its first corner.
Parameters:
width: the width of the rectangleheight: the height of the rectangle
Returns: self for chaining.
width
Sets the second x coordinate to
x1 + width; the value is measured from the first corner, regardless of the existing second corner.Parameters:
width: the width of the rectangle
Returns: self for chaining.
x1
Sets the first x coordinate of the rectangle.
Parameters:
x1: the first x position of the rectangle
Returns: self for chaining.
x2
Sets the second x coordinate of the rectangle.
Parameters:
x2: the second x position of the rectangle
Returns: self for chaining.
y1
Sets the first y coordinate of the rectangle.
Parameters:
y1: the first y position of the rectangle
Returns: self for chaining.
y2
Sets the second y coordinate of the rectangle.
Parameters:
y2: the second y position of the rectangle
Returns: self for chaining.
zIndex
Sets the overlay ordering index; lower values are drawn first. Builders default to zero.
Parameters:
zIndex: the z-index of the rectangle
Returns: self for chaining.