Skip to content

UIImage

Defined in: ui/src/UIImage.ts:41

Displays a texture as a UI element.

Size it on one axis and the other follows the texture’s aspect ratio, even where a flex parent would stretch it. Size both axes and the texture stretches to that box. Size neither and it measures at the texture’s own pixel size, and its parent can stretch it like any other flex child. A flexGrow, flex or flexBasis sizes the main axis as well, so with one of those set the texture stretches as if both axes were sized.

The sprite sits inside a plain container, UIImage.displayObject, whose own space is measured in layout pixels. Layout stretches the sprite inside it, so the element’s scale and rotation stay the game’s.

new UIImage(props): UIImage

Defined in: ui/src/UIImage.ts:53

UIImageProps

UIImage

UIElementBase.constructor

readonly _transform: ElementTransform

Defined in: ui/src/UIElementBase.ts:20

Internal

UIElementBase._transform


readonly displayObject: DisplayContainer

Defined in: ui/src/UIImage.ts:44

UIElementBase.displayObject


readonly sprite: Sprite

Defined in: ui/src/UIImage.ts:43

The sprite drawing the texture, stretched to the layout box.


readonly yogaNode: Node

Defined in: ui/src/UIImage.ts:45

UIElementBase.yogaNode

get rotation(): number

Defined in: ui/src/UIElementBase.ts:50

See LayoutProps.rotation.

number

set rotation(value): void

Defined in: ui/src/UIElementBase.ts:54

number

void

UIElementBase.rotation


get scale(): Readonly<{ x: number; y: number; }>

Defined in: ui/src/UIElementBase.ts:41

See LayoutProps.scale.

Readonly<{ x: number; y: number; }>

set scale(value): void

Defined in: ui/src/UIElementBase.ts:45

number | { x: number; y: number; }

void

UIElementBase.scale


get transformOrigin(): Readonly<{ x: number; y: number; }>

Defined in: ui/src/UIElementBase.ts:32

See LayoutProps.transformOrigin.

Readonly<{ x: number; y: number; }>

set transformOrigin(value): void

Defined in: ui/src/UIElementBase.ts:36

number | { x: number; y: number; }

void

UIElementBase.transformOrigin


get visible(): boolean

Defined in: ui/src/UIImage.ts:157

boolean

set visible(v): void

Defined in: ui/src/UIImage.ts:161

boolean

void

UIElementBase.visible


get zIndex(): number

Defined in: ui/src/UIElementBase.ts:59

See LayoutProps.zIndex.

number

set zIndex(value): void

Defined in: ui/src/UIElementBase.ts:63

number

void

UIElementBase.zIndex

_inspectState(): object

Defined in: ui/src/UIImage.ts:195

Internal

What the Inspector reports for this image: whether it takes part in focus navigation, which is off unless the game asked for it, and whether it holds focus right now. A test reads this instead of a screenshot.

object

focusable: boolean

focused: boolean


applyLayout(): void

Defined in: ui/src/UIImage.ts:127

Scale sprite to match Yoga computed size.

void


protected applyTransformProps(props): void

Defined in: ui/src/UIElementBase.ts:27

Apply the four transform props present in props. A present key holding undefined resets that prop to its default. Throws before writing anything if a value is not finite.

LayoutProps

void

UIElementBase.applyTransformProps


destroy(): void

Defined in: ui/src/UIImage.ts:200

Idempotent — a second call is a no-op.

void

UIElementBase.destroy


update(p): void

Defined in: ui/src/UIImage.ts:166

Partial<UIImageProps>

void

UIElementBase.update

Coding agents: fetch https://yage.dev/llms.txt first and prefer the Markdown references it links over these HTML pages. This page's Markdown counterpart is /llms/packages/ui.md.