Class RectTransform
java.lang.Object
dev.prozilla.pine.core.component.Component
dev.prozilla.pine.core.component.canvas.RectTransform
- All Implemented Interfaces:
Lifecycle
,Printable
,ComponentFinder
,EntityFinder
A base component for positioning canvas elements.
Every canvas element is handled as a rectangle and is anchored to a position on the canvas,
bottom left corner by default.
-
Field Summary
FieldsModifier and TypeFieldDescriptionboolean
If true, this rect won't be arranged by a canvas groupboolean
static final GridAlignment
int
boolean
If true, allows the cursor to pass through this element.boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Gets the canvas component in a parent entity.getName()
int
int
int
getSizeX()
int
getSizeY()
boolean
boolean
isInside
(int x, int y) Checks if a point is inside this rectangle.boolean
Checks if a point is inside this rectangle.static boolean
isInsideRect
(int x, int y, Vector2i rectPosition, Vector2i rectSize) Checks if a point is inside a given rectangle.static boolean
isInsideRect
(Vector2i point, Vector2i rectPosition, Vector2i rectSize) Checks if a point is inside a given rectangle.void
setAnchor
(GridAlignment anchor) void
setPosition
(DualDimension position) void
setSize
(DualDimension size) Methods inherited from class dev.prozilla.pine.core.component.Component
equals, getCamera, getChildWithTag, getComponent, getComponentInParent, getComponentInParent, getComponents, getComponentsInChildren, getEntity, getInput, getLogger, getParentWithTag, getRenderer, getTimer, getTracker, getTransform, getWindow, getWorld, hashCode, setActive, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
currentPosition
-
currentSize
-
cursorHit
public boolean cursorHit -
readyToRender
public boolean readyToRender -
iterations
public int iterations -
position
-
size
-
anchor
-
passThrough
public boolean passThroughIf true, allows the cursor to pass through this element. -
absolutePosition
public boolean absolutePositionIf true, this rect won't be arranged by a canvas group -
canvas
-
DEFAULT_ANCHOR
-
-
Constructor Details
-
RectTransform
public RectTransform()
-
-
Method Details
-
getName
-
isInside
Checks if a point is inside this rectangle.- Returns:
- True if the point is inside the rectangle
-
isInside
public boolean isInside(int x, int y) Checks if a point is inside this rectangle.- Parameters:
x
- X positiony
- Y position- Returns:
- True if the point is inside the rectangle
-
isInsideRect
Checks if a point is inside a given rectangle.- Parameters:
rectPosition
- Position of the rectanglerectSize
- Size of the rectangle- Returns:
- True if the point is inside the rectangle
-
isInsideRect
Checks if a point is inside a given rectangle.- Parameters:
rectPosition
- Position of the rectanglerectSize
- Size of the rectangle- Returns:
- True if the point is inside the rectangle
-
getContext
-
isInCanvasGroup
public boolean isInCanvasGroup() -
getCanvas
Gets the canvas component in a parent entity.- Throws:
IllegalStateException
- When this entity is not a child of an entity with a canvas component.
-
setPosition
-
setSize
-
setAnchor
-
getPositionX
public int getPositionX() -
getPositionY
public int getPositionY() -
getSizeX
public int getSizeX() -
getSizeY
public int getSizeY() -
computeCurrentSize
-