Documentation Index
Fetch the complete documentation index at: https://rive-accessibility.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
A scripted converter used for transforming values between ViewModel data
bindings and Rive properties.
Type parameters:
T: The converter type
I: The input type, must be a DataValue type
(DataValueNumber, DataValueString, DataValueBoolean, DataValueColor, etc)
O: The output type, must be a DataValue type
(DataValueNumber, DataValueString, DataValueBoolean, DataValueColor, etc)
For more information, see Converter Scripts.
Methods
init
init(self: T, context: Context) -> boolean
Called once when the converter is created. Returns true if initialization
succeeds.
-- Called once when the script initializes.
function init(self: MyConverter, context: Context): boolean
-- Return false to stop the script.
return true
end
convert
convert(self: T, input: I) -> O
Converts the input value (a view model property) to an output value.
The input parameter must be a DataValue type.
-- Converts the value when binding from source to target.
function convert(self: MyConverter, input: DataInputs): DataOutput
local dv: DataValueNumber = DataValue.number()
if input:isNumber() then
-- Example: Add 1 to the incoming number
dv.value = (input :: DataValueNumber).value + 1
end
return dv
end
reverseConvert
reverseConvert(self: T, input: O) -> I
Converts the output value back to an input value (a view model property).
The input parameter must be a DataValue type.
function reverseConvert(
self: MyConverter,
input: DataOutput
): DataInputs
local dv: DataValueNumber = DataValue.number()
if input:isNumber() then
-- Example: Subract 1 from the target number
dv.value = (input :: DataValueNumber).value - 1
end
return dv
end
advance
advance(self: T, seconds: number) -> boolean
Optional per-frame update. Returns true if the converter should continue
receiving advance calls.
function advance(self: MyConverter, seconds: number): boolean
return false
end