LavaUI docs

struct Image

Swift

struct Image

Raster image laid out as a Yoga leaf and drawn as a textured quad.

One specified axis keeps the pixel aspect: Image(logo, width: .pt(80)) on a 200×100 bitmap is an 80×40 box. Both auto is the native size; both set is the box contentMode paints into.

Image(logo, width: .pt(64), height: .pt(64))
Image(icon)  // intrinsic pixel size
Image(photo, width: .pt(120))  // height from aspect

Sources/LavaUI/Image.swift:413

Constructors

init(_ image: UIImage, width: Dimension = .auto, height: Dimension = .auto, tint: Color = Color(r: 1, g: 1, b: 1), contentMode: ImageContentMode = .stretch, onClick: (() -> Void)? = nil)

Not documented.

Sources/LavaUI/Image.swift:426

init(path: String, width: Dimension, height: Dimension, placeholder: Color? = nil, placeholderCornerRadius: Float = 0, decodePixels: UInt32? = nil, tint: Color = Color(r: 1, g: 1, b: 1), contentMode: ImageContentMode = .stretch, onClick: (() -> Void)? = nil)

An image identified by file path, loaded on demand and drawn when ready.

Prefer this to branching on ImageStore.imageIfLoaded in a body. Writing it as if let img = …imageIfLoaded(…) { Image(img) } else { placeholder } makes the shape of the view tree depend on whether a decode has finished, so every arriving image has to invalidate body and rebuild the tree. Here the leaf is the same leaf either way; it resolves its own texture at emit, and an arriving image costs one redraw.

width/height must be definite for the decode cap to be derived from them — with .auto there is no box to size against yet, and the file decodes at native resolution. Pass decodePixels to override.

Sources/LavaUI/Image.swift:454

Properties

var contentMode: ImageContentMode

Not documented.

Sources/LavaUI/Image.swift:423

var dumpDetail: String { get }

Not documented.

Sources/LavaUI/Image.swift:490

var height: Dimension

Not documented.

Sources/LavaUI/Image.swift:420

var image: UIImage?

Not documented.

Sources/LavaUI/Image.swift:414

var onClick: (() -> Void)?

Not documented.

Sources/LavaUI/Image.swift:424

var path: String?

Set instead of image by the path initialiser — see its doc comment.

Sources/LavaUI/Image.swift:416

var placeholder: Color?

Not documented.

Sources/LavaUI/Image.swift:417

var placeholderCornerRadius: Float

Not documented.

Sources/LavaUI/Image.swift:418

var tint: Color

Multiplied with sample RGBA (white = no tint).

Sources/LavaUI/Image.swift:422

var width: Dimension

Not documented.

Sources/LavaUI/Image.swift:419

Methods

func mountPrimitive() -> any AnyViewNode

Not documented.

Sources/LavaUI/Image.swift:499

func reconcilePrimitive(_ node: any AnyViewNode) -> any AnyViewNode

Not documented.

Sources/LavaUI/Image.swift:512