Skip to main content
Platform
Language

Buffers

In this example, we will show you how to use the CreativeEditor SDK's CreativeEngine to create buffers through the editor API. Buffers can hold arbitrary data.

Setup#

This example uses the headless CreativeEngine. See the Setup article for a detailed guide. To get started right away, you can also access the block API within a running CE.SDK instance via cesdk.engine.block. Check out the APIs Overview to see that illustrated in more detail.

Limitations#

Buffers are intended for temporary data only.

createBuffer(): string

Create a resizable buffer that can hold arbitrary data.

  • Returns A URI to identify the buffer.
destroyBuffer(uri: string): void

Destroy a buffer and free its resources.

  • uri: The URI of the buffer to destroy.
setBufferData(uri: string, offset: number, data: Uint8Array): void

Set the data of a buffer at a given offset.

  • uri: The URI of the buffer to update.
  • offset: The offset in bytes at which to start writing.
  • data: The data to write.
getBufferData(uri: string, offset: number, length: number): Uint8Array

Get the data of a buffer at a given offset.

  • uri: The URI of the buffer to query.
  • offset: The offset in bytes at which to start reading.
  • length: The number of bytes to read.
  • Returns The data at the given offset.
setBufferLength(uri: string, length: number): void

Set the length of a buffer.

  • uri: The URI of the buffer to update.
  • length: The new length of the buffer in bytes.
getBufferLength(uri: string): number

Get the length of a buffer.

  • uri: The URI of the buffer to query.
  • Returns The length of the buffer in bytes.