Skip to main content

Assets

APIs for image assets and rendering options.


Image​

Drawable image asset. In GPU shader workflows, an image can also expose a GPUTextureView through image:view().

Attributes​

AttributeTypeDescription
widthnumberWidth in pixels (read-only)
heightnumberHeight in pixels (read-only)

Methods​

image:view()​

Returns a GPUTextureView for sampling the image from a shader.

Release tier: Preview / rollout-dependent

image:view(): GPUTextureView

Example:

local image = context:image("portrait")
if image then
local view = image:view()
end

Use the returned view in a shader bind group:

textures = {{ slot = 1, view = image:view() }}

See Also: Renderer.drawImage, GPU Shaders

GPUTextureView.format​

The pinned runtime source declares a texture-view format field, but the August 14 Rive Beta MCP probe could not read it:

local texture = GPUTexture.new({ width = 64, height = 64, renderTarget = true })
local view = texture:view()
print(view.format) -- Live failure: attempt to index userdata with 'format'

Treat this as source-only Early Access material, not a working Editor property. The same live build executed GPU constructors and ranged GPUBuffer writes despite reporting the GPU constructor globals as unknown in the analyzer; that analyzer/runtime mismatch does not make format usable.


ImageFilter​

Defines image sampling behavior during scaling or transformation.

Values​

ValueDescription
bilinearSmooth filtering (default)
nearestPixel-perfect, no interpolation

See Also: Image, ImageSampler


ImageSampler​

Sampling parameters applied when drawing an image, combining wrapping and filtering behavior.

Constructor​

ImageSampler(wrapX, wrapY, filter)​

Creates an ImageSampler with the specified wrapping and filtering options.

ImageSampler(wrapX: ImageWrap, wrapY: ImageWrap, filter: ImageFilter): ImageSampler

Example​

local sampler = ImageSampler("clamp", "clamp", "bilinear")
renderer:drawImage(image, sampler, "srcOver", 1.0)

See Also: ImageFilter, ImageWrap


ImageWrap​

Defines how texture coordinates outside the [0, 1] range are handled.

Values​

ValueDescription
clampClamps coordinates to [0, 1] range
repeatTiles the texture by repeating
mirrorMirrors the texture at boundaries

See Also: ImageSampler, Image


Blob​

Binary data can arrive either as an asset lookup or as a data-bound property. These are separate APIs: context:blob(name) resolves a packaged asset, while viewModel:getBlob(name) returns a mutable Property<Blob>.

Editable documents claimed by a TextFileFormat also export as ordinary Blob assets. The editor-side document callbacks use FormatDocument; the runtime consumer uses context:blob(name). See File Formats.

Attributes​

AttributeTypeDescription
namestringAsset name (read-only)
sizenumberData size in bytes (read-only)
databuffer?Raw binary data; nil for a zero-byte Blob (read-only)

See Also: Context, Property<Blob>

An empty string or empty buffer assigned to a Property<Blob> creates a real zero-byte Blob. Assigning nil clears the property. Repeated reads of an unchanged asset-valued property preserve wrapper identity; a replacement invalidates the cached wrapper.

runtime-v0.1.384 exposes no Blob string-conversion method. Guard data and use buffer.tostring(blob.data) when the bytes represent text; for an empty Blob, size == 0 and data == nil.


DecodedImage​

Raw decoded pixel payload returned by context:decodeImage(buffer).

Release tier: Officially released (advanced surface)

Attributes​

AttributeTypeDescription
databufferPremultiplied RGBA8 bytes (width * height * 4)
widthnumberWidth in pixels
heightnumberHeight in pixels

Example​

local run = async(function()
local ok, decoded = await(context:decodeImage(blob.data))
if ok and decoded then
print(decoded.width, decoded.height)
end
end)

See Also: Context.decodeImage, Promise, Runtime Compatibility Baseline


AudioSource​

Opaque audio asset reference obtained via context:audio(name). Pass to Audio.play() to produce an AudioSound.

Attributes​

AttributeTypeDescription
durationnumberSource duration in seconds (read-only)

Example​

function init(self: MyScript, context: Context): boolean
local source = context:audio("click")
if source then
print("duration:", source.duration)
end
return true
end

See Also: Audio, AudioSound, Context


AudioSound​

A playing audio instance returned by Audio.play() and related methods.

Attributes​

AttributeTypeAccessDescription
volumenumberread/writePlayback volume

Methods​

sound:stop()​

Stops playback.

sound:stop()

sound:pause()​

Pauses playback.

sound:pause()

sound:resume()​

Resumes paused playback.

sound:resume()

sound:play()​

Starts or restarts playback for this sound instance.

sound:play()

The current Editor reference and analyzer accept these three transport methods. The August 14 probe did not execute the calls, so this is static Editor evidence rather than runtime playback evidence.

sound:seek(seconds)​

Seeks to a specific time in seconds.

sound:seek(seconds: number)

sound:seekFrame(frame)​

Seeks to a specific frame.

sound:seekFrame(frame: number)

sound:completed()​

Returns true if playback has finished.

sound:completed(): boolean

sound:time()​

Returns current playback time in seconds.

sound:time(): number

sound:timeFrame()​

Returns current playback time in frames.

sound:timeFrame(): number

See Also: Audio, AudioSource

Next Steps​