RSX Code Reference
    Preparing search index...

    Class Canvas2D

    A 2D scene class that can have a hierarchy of renderable elements.

    The Canvas2D class allows querying elements inside a given area or below a point, as well as creating a command buffer that includes a sequence of commands that need to be executed by a renderer to draw the 2D scene on the screen.

    Index
    • Creates a new empty canvas.

      Parameters

      • quadtreeCenter: Immutable<Vector2>
      • quadtreeExtent: number
      • OptionalisInternalConstructor: boolean

      Returns Canvas2D

    • get draggedElement(): Canvas2DElement

      The dragged element that receives drag mouse events.

      Returns Canvas2DElement

    • set draggedElement(value: Canvas2DElement): void

      Parameters

      • value: Canvas2DElement

      Returns void

    • get focusedElement(): Canvas2DElement

      The focused element that receives mouse events.

      Returns Canvas2DElement

    • set focusedElement(value: Canvas2DElement): void

      Parameters

      • value: Canvas2DElement

      Returns void

    • get root(): Canvas2DElement

      The root element of the canvas. This is provided by default for by canvas.

      Returns Canvas2DElement

    • Clears all contents of the canvas except for the Root element.

      Returns void

    • Finds the nearest element on the canvas closest to point.

      Parameters

      • point: Immutable<Vector2>

        The point to perform query elements around.

      • searchArea: number

        Specifies a square to which the elements will be searched on.

      Returns Canvas2DElement

      A pointer to the matching element, if any.

    • Performs a hit testing on the canvas to find the highest ordered element under point.

      Parameters

      Returns Canvas2DElement

      A pointer to the matching element, if any. Can be null if there are no elements under point.

    • Performs a hit testing on the canvas to find the elements that intersect rectangle.

      Parameters

      • rectangle: Immutable<Rect2>

        The rectangle to perform hit-testing for.

      Returns Canvas2DElement[]

      A vector containing the matching elements.

    • Virtual

      A method called to dispatch events for elements.

      Keyboard and text events are always sent to the currently focused element, if any.

      Parameters

      • event: ButtonEvent

        The event received on the element.

      Returns boolean

      True if the event was consumed and must not be propagated to the parent; false otherwise.

    • Virtual

      A method called to dispatch events for elements.

      Mouse events are always delivered to the highest z-ordered element under the location the event has occurred, except for UIMouseEventType::MouseUp and UIMouseEventType::MouseDrag which will always be forwarded to the element to which UIMouseEventType::MouseDown was first sent to.

      Parameters

      Returns boolean

      True if the event was consumed and must not be propagated to the parent; false otherwise.

    • Virtual

      A method called to dispatch events for elements.

      Keyboard and text events are always sent to the currently focused element, if any.

      Parameters

      Returns boolean

      True if the event was consumed and must not be propagated to the parent; false otherwise.

    • Requests a full redraw the next time draw() is called.

      This method must be called whenever the render target texture for the canvas changes or is recreated to ensure that the whole canvas is redrawn in those instances.

      Returns void

    onRegisterElement: Event<[p0: Canvas2DElement]>

    An event triggered whenever a element becomes dirty and the canvas needs to redraw. This event will is only triggered once until draw() is called.

    onUnregisterElement: Event<[p0: Canvas2DElement]>

    An event triggered whenever a element becomes dirty and the canvas needs to redraw. This event will is only triggered once until draw() is called.

    onDirty: Event<[]>

    An event triggered whenever a element becomes dirty and the canvas needs to redraw. This event will is only triggered once until draw() is called.