Talos docs

ViewRect

Since 0.7

A view's rectangle, fractions of the window from its top-left corner.

Plain text

Signature

export interface ViewRect {
  /** Left edge, as a fraction of the window width (0 is the left edge). */
  readonly x: number
  /** Top edge, as a fraction of the window height (0 is the top edge). */
  readonly y: number
  /** Width, as a fraction of the window width. */
  readonly width: number
  /** Height, as a fraction of the window height. */
  readonly height: number
}

Import: import type { ViewRect } from "@argus/api"

Members

MemberSignatureDescription
xreadonly x: numberLeft edge, as a fraction of the window width (0 is the left edge).
yreadonly y: numberTop edge, as a fraction of the window height (0 is the top edge).
widthreadonly width: numberWidth, as a fraction of the window width.
heightreadonly height: numberHeight, as a fraction of the window height.

Example

The tested fixture fixtures/app/agent.ts.

import type { Behavior } from "@argus/api"

// Sends a nav agent to `props.target` once, then reports arrival through ctx.state so the
// test can read it without polling the crowd directly.
export default {
  init(ctx) {
    ctx.state.arrived = false
    ctx.nav?.goTo(ctx.props.target as [number, number, number])
  },
  update(ctx) {
    if (ctx.nav?.arrived) ctx.state.arrived = true
  },
} satisfies Behavior