@kayelaa/canvas API - v0.2.15
    Preparing search index...

    Variable useRectConst

    useRect: (type?: "self" | "parent" | "disposableSelf") => KaylaRect = ...

    Returns a convenient, mutable facade for the current entity's rectangle properties.

    This hook MUST be called at the top level of a component function — never inside loops, conditions, nested functions, or callbacks. The call order of all hooks is strictly fixed across every refresh; reordering calls will corrupt internal state.

    Provides direct getters/setters for x, y, width, height, z, pos (live Vector2), left/right/top/bottom, plus helpers like .isCollidingWith() and .isHovered().

    Recommended over useEntity() for most cases — cleaner API, same performance, better discoverability.

    Type Declaration

      • (type?: "self" | "parent" | "disposableSelf"): KaylaRect
      • Parameters

        • type: "self" | "parent" | "disposableSelf" = "self"

        Returns KaylaRect

        Mutable rect facade (changes never trigger refresh)

    const rect = useRect();

    useTick(dt => {
    rect.x += 180 * dt; // alias setter
    rect.pos.y = 300 + Math.sin(Date.now() * 0.001) * 80; // live Vector2
    rect.z = Math.floor(rect.x / 100); // sort by horizontal position
    });

    useTick(() => {
    if (rect.isHovered()) {
    rect.width = 80; // visual feedback
    }
    });

    useEntity — when you need the raw LEA entity methods/properties