Preparing search index...

    Represents a 2D rectangle with position and dimensions.

        // Editor.Rect is a 2D axis-aligned rectangle defined by left/right/bottom/top
    // edges. It is used by ScreenTransform to express its anchor and offset
    // rectangles relative to the parent canvas.
    const model = this.pluginSystem.findInterface(Editor.Model.IModel) as Editor.Model.IModel;
    const scene = model.project.scene;

    const obj = scene.createSceneObject('UiElement');
    const st = obj.addComponent('ScreenTransform') as Editor.Components.ScreenTransform;

    // Anchor to the full parent rect (0..1 on both axes).
    st.anchor = Editor.Rect.fromMinMax(new vec2(0, 0), new vec2(1, 1));

    // Offset expressed in points: shrink by 20 on every side.
    const offset = Editor.Rect.create(20, -20, 20, -20);
    st.offset = offset;

    console.log(`offset size: ${offset.getSize()}, center: ${offset.getCenter()}`);
    Index

    Constructors

    Properties

    bottom: number

    Y coordinate of the bottom edge.

    left: number

    X coordinate of the left edge.

    leftBottom: vec2

    Corner point at the left and bottom edges as a vec2.

    right: number

    X coordinate of the right edge.

    rightTop: vec2

    Corner point at the right and top edges as a vec2.

    top: number

    Y coordinate of the top edge.

    Methods

    • Creates a new Rect instance.

      Parameters

      • left: number
      • right: number
      • bottom: number
      • top: number

      Returns Editor.Rect

    • Returns the center point of the rectangle as a vec2.

      Returns vec2

    • Returns the width and height of the rectangle as a vec2.

      Returns vec2

    • Moves the rectangle so its center is at the given vec2 position.

      Parameters

      Returns void

    • Sets the width and height of the rectangle from a vec2.

      Parameters

      Returns void

    • Converts the rectangle to a vec4 (left, bottom, right, top).

      Returns vec4