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


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 asset accessed via context:blob(name).

Attributes

AttributeTypeDescription
namestringAsset name (read-only)
sizenumberData size in bytes (read-only)
databufferRaw binary data (read-only)

See Also: Context


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: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