Package limn.graphics
Record Class Rect
java.lang.Object
java.lang.Record
limn.graphics.Rect
- Record Components:
x- left edgey- top edgewidth- width (may be 0, never negative)height- height (may be 0, never negative)
Immutable axis-aligned rectangle in logical points.
-
Constructor Summary
ConstructorsConstructorDescriptionRect(float x, float y, float width, float height) Creates an instance of aRectrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfloatbottom()y + height.floatcenterX()Horizontal midpoint.floatcenterY()Vertical midpoint.booleancontains(float px, float py) Whether the point is inside, taking the left and top edges and excluding right and bottom.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.floatheight()Returns the value of theheightrecord component.inflate(float amount) floatright()x + width.final StringtoString()Returns a string representation of this record class.floatwidth()Returns the value of thewidthrecord component.floatx()Returns the value of thexrecord component.floaty()Returns the value of theyrecord component.
-
Constructor Details
-
Method Details
-
right
public float right()x + width. -
bottom
public float bottom()y + height. -
centerX
public float centerX()Horizontal midpoint. -
centerY
public float centerY()Vertical midpoint. -
contains
public boolean contains(float px, float py) Whether the point is inside, taking the left and top edges and excluding right and bottom. -
intersect
- Returns:
- the intersection with
other(a zero-sized rect if disjoint)
-
union
- Returns:
- the smallest rect containing both this and
other(zero-sized rects contribute their origin)
-
inflate
- Returns:
- this rect grown by
amounton every side (shrunk if negative)
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
x
public float x()Returns the value of thexrecord component.- Returns:
- the value of the
xrecord component
-
y
public float y()Returns the value of theyrecord component.- Returns:
- the value of the
yrecord component
-
width
public float width()Returns the value of thewidthrecord component.- Returns:
- the value of the
widthrecord component
-
height
public float height()Returns the value of theheightrecord component.- Returns:
- the value of the
heightrecord component
-