Record Class Sprite
java.lang.Object
java.lang.Record
cit244.api.image.Sprite
- Record Components:
image- source imagex- left edge of the region, in source-image pixelsy- top edge of the region, in source-image pixelswidth- region width in pixelsheight- region height in pixels
A rectangular region of an
Image, measured in source-image pixels.
A sprite does not store a screen position. Use at(double, double)
to create drawing instructions for it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionat(double x, double y) Creates drawing instructions with a top-left anchor and native scale.Creates drawing instructions at the given screen position.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intheight()Returns the value of theheightrecord component.image()Returns the value of theimagerecord component.final StringtoString()Returns a string representation of this record class.intwidth()Returns the value of thewidthrecord component.intx()Returns the value of thexrecord component.inty()Returns the value of theyrecord component.
-
Constructor Details
-
Sprite
Checks that the selected region fits inside the source image.- Throws:
NullPointerException- if image is nullIllegalArgumentException- if the region is empty or outside the image
-
-
Method Details
-
at
Creates drawing instructions with a top-left anchor and native scale.- Parameters:
x- screen x-coordinatey- screen y-coordinate- Returns:
- drawing instructions for this sprite
-
at
Creates drawing instructions at the given screen position.- Parameters:
position- location of the default top-left anchor- Returns:
- drawing instructions for this sprite
-
toString
-
hashCode
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
image
-
x
-
y
-
width
-
height
-