yodaRT.light. LightRenderingContext

The LightRenderingContext object is provided for rendering your light and sound effects.

Constructor

new LightRenderingContext()

Methods

playAwake()

Play and monitor the sounds on awaken-time, it plays the system awaken audio ramdonly which are both located at /opt/light/awake_0x.wav.

sound(uri, selfopt, optionsopt) → {object}

Play the sound effect by a uri, which is ends with .wav, .ogg and .opus, which means that only supports WAV, OGG and OPUS formats for sound effects.

Parameters:
Name Type Attributes Description
uri string

the sound resource uri.

self string <optional>

as prefix path if uri start with 'self://' protocol.

options object <optional>

the options to play the audio.

Name Type Attributes Default Description
ignore boolean <optional>
false

ignore this system audio if others(tts, bt, music) are playing.

Returns:
Type:
object

a MediaPlayer instance

stop()

Clear all handles.

render()

Start rendering the current effect.

clear()

Clear the effects buffer.

pixel(pos, r, g, b, a)

Write a single pixel.

Parameters:
Name Type Description
pos number

the position of the pixel to be written

r number

Red value. from 0 to 255

g number

Green value. from 0 to 255

b number

Red value. from 0 to 255

a number

Transparency value. from 0 to 1

fill(r, g, b, a)

Fill all pixels to the specified color.

Parameters:
Name Type Description
r number

Red value. from 0 to 255

g number

Green value. from 0 to 255

b number

Red value. from 0 to 255

a number

Transparency value. from 0 to 1

requestAnimationFrame(cb, interval)

Perform callback after the specified time.

Parameters:
Name Type Description
cb function

callback

interval number

millisecond

transition(from, to, duration, fps, cb) → {Promise.<null>}

Make a transition. the fourth parameter will be true in callback when transition end.

Parameters:
Name Type Description
from yodaRT.light.Color

Specify the starting color of the transition.

to yodaRT.light.Color

Specify the end color of the transition.

duration number

Specify the duration of the transition.

fps number

Specify the fps of the transition.

cb yodaRT.light.LightRenderingContext~renderCallback

a function to receive rgb color in transitions.

Returns:
Type:
Promise<Null>

when the last is computed, resolve the promise.

breathing(r, g, b, duration, fps, cb) → {Promise.<null>}

Make a breathing effect. The fourth parameter will be true in callback when breathing end.

Parameters:
Name Type Description
r number

Red value of the breathing effect.

g number

Green value of the breathing effect.

b number

Blue value of the breathing effect.

duration number

Specify the duration of the transition.

fps number

Specify the fps of the transition.

cb yodaRT.light.LightRenderingContext~renderCallback

a function to receive rgb color in breathing.

Returns:
Type:
Promise<Null>

when the last is computed, resolve the promise.

Type Definitions

renderCallback(r, g, b, last)

Parameters:
Name Type Description
r number

the REG color.

g number

the GREEN color.

b number

the BLUE color.

last boolean

is the last frame