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

public class RectTransform extends Component
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 Details

    • currentPosition

      public Vector2i currentPosition
    • currentSize

      public Vector2i currentSize
    • cursorHit

      public boolean cursorHit
    • readyToRender

      public boolean readyToRender
    • iterations

      public int iterations
    • position

      public DualDimension position
    • size

      public DualDimension size
    • anchor

      public GridAlignment anchor
    • passThrough

      public boolean passThrough
      If true, allows the cursor to pass through this element.
    • absolutePosition

      public boolean absolutePosition
      If true, this rect won't be arranged by a canvas group
    • canvas

      public CanvasRenderer canvas
    • DEFAULT_ANCHOR

      public static final GridAlignment DEFAULT_ANCHOR
  • Constructor Details

    • RectTransform

      public RectTransform()
  • Method Details

    • getName

      public String getName()
      Overrides:
      getName in class Component
    • isInside

      public boolean isInside(Vector2i point)
      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 position
      y - Y position
      Returns:
      True if the point is inside the rectangle
    • isInsideRect

      public static boolean isInsideRect(Vector2i point, Vector2i rectPosition, Vector2i rectSize)
      Checks if a point is inside a given rectangle.
      Parameters:
      rectPosition - Position of the rectangle
      rectSize - Size of the rectangle
      Returns:
      True if the point is inside the rectangle
    • isInsideRect

      public static boolean isInsideRect(int x, int y, Vector2i rectPosition, Vector2i rectSize)
      Checks if a point is inside a given rectangle.
      Parameters:
      rectPosition - Position of the rectangle
      rectSize - Size of the rectangle
      Returns:
      True if the point is inside the rectangle
    • getContext

      public CanvasContext getContext()
    • isInCanvasGroup

      public boolean isInCanvasGroup()
    • getCanvas

      public CanvasRenderer getCanvas() throws IllegalStateException
      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

      public void setPosition(DualDimension position)
    • setSize

      public void setSize(DualDimension size)
    • setAnchor

      public void setAnchor(GridAlignment anchor)
    • getPositionX

      public int getPositionX()
    • getPositionY

      public int getPositionY()
    • getSizeX

      public int getSizeX()
    • getSizeY

      public int getSizeY()
    • computeCurrentSize

      public void computeCurrentSize(DualDimension size)