native_animate.h
Overview
Defines a set of animation APIs of ArkUI on the native side. The APIs in native_animate.h must be called in the main thread.
File to include: <arkui/native_animate.h>
Library: libace_ndk.z.so
System capability: SystemCapability.ArkUI.ArkUI.Full
Since: 12
Related module: ArkUI_NativeModule
Sample: AnimationNDK
Summary
Structs
| Name | typedef Keyword | Description |
|---|---|---|
| ArkUI_ExpectedFrameRateRange | ArkUI_ExpectedFrameRateRange | Defines a struct for the expected frame rate range of the animation. |
| ArkUI_AnimateCompleteCallback | ArkUI_AnimateCompleteCallback | Defines the callback type for when the animation playback is complete. |
| ArkUI_NativeAnimateAPI_1 | ArkUI_NativeAnimateAPI_1 | Defines a struct for the animation APIs of ArkUI on the native side. |
| ArkUI_AnimateOption | ArkUI_AnimateOption | Animation settings. |
| ArkUI_Curve | ArkUI_Curve | Defines an interpolation curve. |
| ArkUI_Curve* | ArkUI_CurveHandle | Defines a struct for the pointer to an interpolation curve. |
| ArkUI_KeyframeAnimateOption | ArkUI_KeyframeAnimateOption | Defines the keyframe animation parameter object. |
| ArkUI_AnimatorOption | ArkUI_AnimatorOption | Defines the animator parameter object. |
| ArkUI_Animator* | ArkUI_AnimatorHandle | Defines the pointer to an animator object. |
| ArkUI_AnimatorEvent | ArkUI_AnimatorEvent | Defines the animator callback event object. |
| ArkUI_AnimatorOnFrameEvent | ArkUI_AnimatorOnFrameEvent | Defines the callback object when the animator receives a frame. |
| ArkUI_TransitionEffect | ArkUI_TransitionEffect | Defines the transition effect. |
Functions
Function Description
OH_ArkUI_AnimateOption_Create()
ArkUI_AnimateOption* OH_ArkUI_AnimateOption_Create()
Description
Creates an animation configuration.
Since: 12
Return value
| Type | Description |
|---|---|
| ArkUI_AnimateOption* | Pointer to the created animation configuration. |
OH_ArkUI_AnimateOption_Dispose()
void OH_ArkUI_AnimateOption_Dispose(ArkUI_AnimateOption* option)
Description
Disposes of an animation configuration.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Pointer to an animation configuration. If option is set to NULL, the operation is invalid. |
OH_ArkUI_AnimateOption_GetDuration()
uint32_t OH_ArkUI_AnimateOption_GetDuration(ArkUI_AnimateOption* option)
Description
Obtains the animation duration, in milliseconds.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Pointer to an animation configuration. If option is set to NULL, 0 is returned. |
Return value
| Type | Description |
|---|---|
| uint32_t | Animation duration, in milliseconds. If option is invalid, 0 is returned. |
OH_ArkUI_AnimateOption_GetTempo()
float OH_ArkUI_AnimateOption_GetTempo(ArkUI_AnimateOption* option)
Description
Obtains the playback speed of an animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Pointer to an animation configuration. If option is set to NULL, 0.0 is returned. |
Return value
| Type | Description |
|---|---|
| float | Animation playback speed. Value range: [0, +∞). If option is invalid, 0.0 is returned. |
OH_ArkUI_AnimateOption_GetCurve()
ArkUI_AnimationCurve OH_ArkUI_AnimateOption_GetCurve(ArkUI_AnimateOption* option)
Description
Obtains an animation curve.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Pointer to an animation configuration. If option is set to NULL, -1 is returned. |
Return value
| Type | Description |
|---|---|
| ArkUI_AnimationCurve | Animation curve. If option is invalid,-1 is returned. |
OH_ArkUI_AnimateOption_GetDelay()
int32_t OH_ArkUI_AnimateOption_GetDelay(ArkUI_AnimateOption* option)
Description
Obtains the animation delay, in milliseconds.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Pointer to an animation configuration. If option is set to NULL, 0 is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Delay of animation playback. If option is invalid, 0 is returned. |
OH_ArkUI_AnimateOption_GetIterations()
int32_t OH_ArkUI_AnimateOption_GetIterations(ArkUI_AnimateOption* option)
Description
Obtains the number of times that an animation is played.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Pointer to an animation configuration. If option is set to NULL, 0 is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Number of times that the animation is played. If option is invalid, 0 is returned. |
OH_ArkUI_AnimateOption_GetPlayMode()
ArkUI_AnimationPlayMode OH_ArkUI_AnimateOption_GetPlayMode(ArkUI_AnimateOption* option)
Description
Obtains the playback mode of an animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Pointer to an animation configuration. If option is set to NULL, -1 is returned. |
Return value
| Type | Description |
|---|---|
| ArkUI_AnimationPlayMode | Animation playback mode. If option is invalid,-1 is returned. |
OH_ArkUI_AnimateOption_GetExpectedFrameRateRange()
ArkUI_ExpectedFrameRateRange* OH_ArkUI_AnimateOption_GetExpectedFrameRateRange(ArkUI_AnimateOption* option)
Description
Obtains the expected frame rate range of an animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Pointer to an animation configuration. If option is set to NULL, NULL is returned. |
Return value
| Type | Description |
|---|---|
| ArkUI_ExpectedFrameRateRange* | Expected frame rate range of the animation, in fps. If option is invalid, NULL is returned. |
OH_ArkUI_AnimateOption_SetDuration()
void OH_ArkUI_AnimateOption_SetDuration(ArkUI_AnimateOption* option, int32_t value)
Description
Sets the animation duration, in milliseconds.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Pointer to an animation configuration. If option is set to NULL, the operation is invalid. |
| int32_t value | Animation duration, in milliseconds. Value range: [0, +∞). If the value is less than 0, 0 is used. |
OH_ArkUI_AnimateOption_SetTempo()
void OH_ArkUI_AnimateOption_SetTempo(ArkUI_AnimateOption* option, float value)
Description
Sets the playback speed of an animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Pointer to an animation configuration. If option is set to NULL, the operation is invalid. |
| float value | Animation playback speed. Value range: [0, +∞). NOTE If the value is less than 0, the default value 1 is used. |
OH_ArkUI_AnimateOption_SetCurve()
void OH_ArkUI_AnimateOption_SetCurve(ArkUI_AnimateOption* option, ArkUI_AnimationCurve value)
Description
Animation curve.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Pointer to an animation configuration. If option is set to NULL, the operation is invalid. |
| ArkUI_AnimationCurve value | Animation curve. Default value: ARKUI_CURVE_LINEAR. You are advised to use ARKUI_CURVE_EASE_IN_OUT to obtain a smoother animation effect. If the value is abnormal, the setting is invalid. |
OH_ArkUI_AnimateOption_SetDelay()
void OH_ArkUI_AnimateOption_SetDelay(ArkUI_AnimateOption* option, int32_t value)
Description
Sets the animation delay, in milliseconds.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Pointer to an animation configuration. If option is set to NULL, the operation is invalid. |
| int32_t value | Animation delay, in milliseconds. Value range: (-∞, +∞). Default value: 0, indicating no animation delay. A value greater than 0 means to begin the animation after the specified amount of time has elapsed. A value less than 0 means to begin the animation in advance. If value is less than 0 and the absolute value of value is less than the actual animation duration, the animation starts its first frame from the state at the absolute value. If the absolute value of value is greater than or equal to the actual animation duration, the animation starts its first frame from the end state. The actual animation duration is equal to the duration of a single animation multiplied by the number of animation playback times. |
OH_ArkUI_AnimateOption_SetIterations()
void OH_ArkUI_AnimateOption_SetIterations(ArkUI_AnimateOption* option, int32_t value)
Description
Sets the number of times that an animation is played.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Pointer to an animation configuration. If option is set to NULL, the operation is invalid. |
| int32_t value | Number of times that the animation is played. Value range: [-1, +∞). If this parameter is set to 0, the animation is not played. If this parameter is set to -1, the animation is played for an infinite number of times. Default value: 1 (played once). If the value is less than -1, the operation is invalid. |
OH_ArkUI_AnimateOption_SetPlayMode()
void OH_ArkUI_AnimateOption_SetPlayMode(ArkUI_AnimateOption* option, ArkUI_AnimationPlayMode value)
Description
Sets the playback mode for an animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Pointer to an animation configuration. If option is set to NULL, the operation is invalid. |
| ArkUI_AnimationPlayMode value | Animation playback mode. Default value: ARKUI_ANIMATION_PLAY_MODE_NORMAL. If the value is abnormal, the operation is invalid. |
OH_ArkUI_AnimateOption_SetExpectedFrameRateRange()
void OH_ArkUI_AnimateOption_SetExpectedFrameRateRange(ArkUI_AnimateOption* option, ArkUI_ExpectedFrameRateRange* value)
Description
Defines a struct for the expected frame rate range of the animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Pointer to an animation configuration. If option is set to NULL, the operation is invalid. |
| ArkUI_ExpectedFrameRateRange* value | Expected frame rate range of the animation, in fps. If value is set to NULL, the operation is invalid. |
OH_ArkUI_AnimateOption_SetICurve()
void OH_ArkUI_AnimateOption_SetICurve(ArkUI_AnimateOption* option, ArkUI_CurveHandle value)
Description
Sets the animation curve for an animation.
NOTE
This API takes precedence over OH_ArkUI_AnimateOption_SetCurve.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Animator animation parameters. If option is set to NULL, the operation is invalid. |
| ArkUI_CurveHandle value | Animation curve parameters. If value is set to NULL, the operation is invalid. |
OH_ArkUI_AnimateOption_GetICurve()
ArkUI_CurveHandle OH_ArkUI_AnimateOption_GetICurve(ArkUI_AnimateOption* option)
Description
Obtains the animation curve of an animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimateOption* option | Animator animation parameters. If option is set to NULL, NULL is returned. |
Return value
| Type | Description |
|---|---|
| ArkUI_CurveHandle | Animation curve parameters. Returns NULL if the option parameter is invalid. |
OH_ArkUI_KeyframeAnimateOption_Create()
ArkUI_KeyframeAnimateOption* OH_ArkUI_KeyframeAnimateOption_Create(int32_t size)
Description
Creates a keyframe animation parameter object.
Since: 12
Parameters
| Name | Description |
|---|---|
| int32_t size | Number of keyframe animation states. Returns NULL if the value of size is less than 0. |
Return value
| Type | Description |
|---|---|
| ArkUI_KeyframeAnimateOption* | Keyframe animation parameter object. If the value of size is less than 0 or if option is abnormal, NULL is returned. |
OH_ArkUI_KeyframeAnimateOption_Dispose()
void OH_ArkUI_KeyframeAnimateOption_Dispose(ArkUI_KeyframeAnimateOption* option)
Description
Disposes of a keyframe animation parameter object.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_KeyframeAnimateOption* option | Keyframe animation parameter object. If option is set to NULL, the operation is invalid. |
OH_ArkUI_KeyframeAnimateOption_SetDelay()
int32_t OH_ArkUI_KeyframeAnimateOption_SetDelay(ArkUI_KeyframeAnimateOption* option, int32_t value)
Description
Sets the overall delay of a keyframe animation, in milliseconds. By default, the keyframe animation starts without any delay.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_KeyframeAnimateOption* option | Keyframe animation parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| int32_t value | Animation delay, in milliseconds. Value range: (-∞, +∞). Default value: 0, indicating no animation delay. A value greater than 0 means to begin the animation after the specified amount of time has elapsed. A value less than 0 means to begin the animation in advance. If value is less than 0 and the absolute value of value is less than the actual animation duration, the animation starts its first frame from the state at the absolute value. If the absolute value of value is greater than or equal to the actual animation duration, the animation starts its first frame from the end state. The actual animation duration is equal to the duration of a single animation multiplied by the number of animation playback times. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_KeyframeAnimateOption_SetIterations()
int32_t OH_ArkUI_KeyframeAnimateOption_SetIterations(ArkUI_KeyframeAnimateOption* option, int32_t value)
Description
Sets the number of times that the keyframe animation is played. By default, the animation is played once. The value -1 indicates that the animation is played for an unlimited number of times. The value 0 indicates that no animation is played.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_KeyframeAnimateOption* option | Keyframe animation parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| int32_t value | Number of times that the animation is played. Value range: [-1, +∞). If this parameter is set to 0, the animation is not played. If this parameter is set to -1, the animation is played for an infinite number of times. Default value: 1, indicating that the animation is played once. If the value is less than -1, the operation is invalid, and the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_KeyframeAnimateOption_RegisterOnFinishCallback()
int32_t OH_ArkUI_KeyframeAnimateOption_RegisterOnFinishCallback(ArkUI_KeyframeAnimateOption* option, void* userData, void (*onFinish)(void* userData))
Description
Sets the callback invoked when the keyframe animation playback is complete. This function is called after the keyframe animation has played for the specified number of times.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_KeyframeAnimateOption* option | Keyframe animation parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| void* userData | Pointer to a custom object. Abnormal value processing is not involved. |
| void (*onFinish)(void* userData) | Callback function. userData: input parameter of the callback function, a user-defined object pointer. If onFinish is set to NULL, the operation is invalid. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_KeyframeAnimateOption_SetExpectedFrameRate()
int32_t OH_ArkUI_KeyframeAnimateOption_SetExpectedFrameRate(ArkUI_KeyframeAnimateOption* option, ArkUI_ExpectedFrameRateRange* frameRate)
Description
Sets the expected frame rate for a keyframe animation.
Since: 19
Parameters
| Name | Description |
|---|---|
| ArkUI_KeyframeAnimateOption* option | Keyframe animation parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| ArkUI_ExpectedFrameRateRange* frameRate | Expected frame rate for the keyframe animation. If frameRate is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_KeyframeAnimateOption_SetDuration()
int32_t OH_ArkUI_KeyframeAnimateOption_SetDuration(ArkUI_KeyframeAnimateOption* option, int32_t value, int32_t index)
Description
Sets the duration of a keyframe animation, in milliseconds.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_KeyframeAnimateOption* option | Keyframe animation parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| int32_t value | Keyframe animation duration, in ms. The default value is 1000 ms. Value range: [0, +∞). If the value is less than 0, 0 is used. |
| int32_t index | Index of the keyframe state segment. If the value of index is less than 0, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_KeyframeAnimateOption_SetCurve()
int32_t OH_ArkUI_KeyframeAnimateOption_SetCurve(ArkUI_KeyframeAnimateOption* option, ArkUI_CurveHandle value, int32_t index)
Description
Sets the animation curve for a specific keyframe animation segment.
NOTE
Because the duration of the springMotion, responsiveSpringMotion, and interpolatingSpring curves does not take effect, these curves are not supported.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_KeyframeAnimateOption* option | Keyframe animation parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| ArkUI_CurveHandle value | Animation curve to set. Default value: ARKUI_CURVE_EASE_IN_OUT. |
| int32_t index | Index of the keyframe state segment. Value range: [0, size – 1], where size indicates the number of keyframe animation states. If the value of index is less than 0 or out of range, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback()
int32_t OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback(ArkUI_KeyframeAnimateOption* option, void* userData, void (*event)(void* userData), int32_t index)
Description
Sets the closure function of the state at the time of the keyframe, that is, the state to be reached at the time of the keyframe.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_KeyframeAnimateOption* option | Keyframe animation parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| void* userData | Pointer to a user-defined object. Abnormal value processing is not involved. |
| void (*event)(void* userData) | Closure function. If event is set to NULL, the operation is invalid. |
| int32_t index | Index of the keyframe state segment. Value range: [0, size – 1], where size indicates the number of keyframe animation states. If the value of index is less than 0 or out of range, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_KeyframeAnimateOption_GetDelay()
int32_t OH_ArkUI_KeyframeAnimateOption_GetDelay(ArkUI_KeyframeAnimateOption* option)
Description
Obtains the overall delay of a keyframe animation, in milliseconds.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_KeyframeAnimateOption* option | Keyframe animation parameters. If option is set to NULL, 0 is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Overall delay, in milliseconds. If option is invalid, 0 is returned. |
OH_ArkUI_KeyframeAnimateOption_GetIterations()
int32_t OH_ArkUI_KeyframeAnimateOption_GetIterations(ArkUI_KeyframeAnimateOption* option)
Description
Obtains the number of times that a keyframe animation is played.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_KeyframeAnimateOption* option | Keyframe animation parameters. If option is set to NULL, 0 is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Number of times that the animation is played. If option is invalid, 0 is returned. |
OH_ArkUI_KeyframeAnimateOption_GetExpectedFrameRate()
ArkUI_ExpectedFrameRateRange* OH_ArkUI_KeyframeAnimateOption_GetExpectedFrameRate(ArkUI_KeyframeAnimateOption* option)
Description
Obtains the expected frame rate from keyframe animation parameters.
Since: 19
Parameters
| Name | Description |
|---|---|
| ArkUI_KeyframeAnimateOption* option | Keyframe animation parameters. If option is set to NULL, NULL is returned. |
Return value
| Type | Description |
|---|---|
| ArkUI_ExpectedFrameRateRange* | Returns the expected frame rate obtained. If option is invalid, NULL is returned. |
OH_ArkUI_KeyframeAnimateOption_GetDuration()
int32_t OH_ArkUI_KeyframeAnimateOption_GetDuration(ArkUI_KeyframeAnimateOption* option, int32_t index)
Description
Obtains the duration of a specific state in a keyframe animation, in milliseconds.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_KeyframeAnimateOption* option | Keyframe animation parameters. If option is set to NULL, 0 is returned. |
| int32_t index | Index of the keyframe state segment. If the value of index is less than 0, 0 is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Duration, in milliseconds. If option is invalid, 0 is returned. |
OH_ArkUI_KeyframeAnimateOption_GetCurve()
ArkUI_CurveHandle OH_ArkUI_KeyframeAnimateOption_GetCurve(ArkUI_KeyframeAnimateOption* option, int32_t index)
Description
Obtains the animation curve of a specific state in a keyframe animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_KeyframeAnimateOption* option | Keyframe animation parameters. If option is set to NULL, NULL is returned. |
| int32_t index | Index of the keyframe state segment. If the value of index is less than 0, NULL is returned. |
Return value
| Type | Description |
|---|---|
| ArkUI_CurveHandle | Animation curve. If the parameter is abnormal, NULL is returned. |
OH_ArkUI_AnimatorOption_Create()
ArkUI_AnimatorOption* OH_ArkUI_AnimatorOption_Create(int32_t keyframeSize)
Description
Creates an AnimatorOption object.
NOTE
If the value of keyframeSize is greater than 0, the animation interpolation start point is 0, and the animation interpolation end point is 1; no setting is allowed.
Since: 12
Parameters
| Name | Description |
|---|---|
| int32_t keyframeSize | Number of keyframes. If the value of keyframeSize is less than 0, NULL is returned. |
Return value
| Type | Description |
|---|---|
| ArkUI_AnimatorOption* | Pointer to the animator parameter object. If the value of size is less than 0 or if option is abnormal, NULL is returned. |
OH_ArkUI_AnimatorOption_Dispose()
void OH_ArkUI_AnimatorOption_Dispose(ArkUI_AnimatorOption* option)
Description
Disposes of an AnimatorOption object.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. If option is set to NULL, the operation is invalid. |
OH_ArkUI_AnimatorOption_SetDuration()
int32_t OH_ArkUI_AnimatorOption_SetDuration(ArkUI_AnimatorOption* option, int32_t value)
Description
Sets the duration of an animator animation, in milliseconds.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| int32_t value | Playback duration, in ms. The default value is 0 ms. Value range: [0, +∞). If the value is less than 0, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_AnimatorOption_SetDelay()
int32_t OH_ArkUI_AnimatorOption_SetDelay(ArkUI_AnimatorOption* option, int32_t value)
Description
Sets the delay time of the animator playback, in milliseconds.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| int32_t value | Animation delay, in milliseconds. Value range: (-∞, +∞). Default value: 0, indicating no animation delay. A value greater than 0 means to begin the animation after the specified amount of time has elapsed. A value less than 0 means to begin the animation in advance. If value is less than 0 and the absolute value of value is less than the actual animation duration, the animation starts its first frame from the state at the absolute value. If the absolute value of value is greater than or equal to the actual animation duration, the animation starts its first frame from the end state. The actual animation duration is equal to the duration of a single animation multiplied by the number of animation playback times. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_AnimatorOption_SetIterations()
int32_t OH_ArkUI_AnimatorOption_SetIterations(ArkUI_AnimatorOption* option, int32_t value)
Description
Sets the number of times that an animator animation is played. By default, the animation is played once. The value -1 indicates that the animation is played for an unlimited number of times. The value 0 indicates that no animation is played.
NOTE
If this parameter is set to a negative value other than -1, the value is invalid. In this case, the animation is played once.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| int32_t value | Value range: [-1, +∞). If this parameter is set to 0, the animation is not played. If this parameter is set to -1, the animation is played for an infinite number of times. Default value: 1 (played once). If the value is less than -1, the operation is invalid. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_AnimatorOption_SetFill()
int32_t OH_ArkUI_AnimatorOption_SetFill(ArkUI_AnimatorOption* option, ArkUI_AnimationFillMode value)
Description
Sets the status of the component before and after the animator animation execution.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| ArkUI_AnimationFillMode value | Status of the component before and after the animator animation execution. Default value: ARKUI_ANIMATION_FILL_MODE_FORWARDS. If the value is less than 0, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_AnimatorOption_SetDirection()
int32_t OH_ArkUI_AnimatorOption_SetDirection(ArkUI_AnimatorOption* option, ArkUI_AnimationDirection value)
Description
Set the playback direction.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| ArkUI_AnimationDirection value | Animation playback direction. If the value is less than 0, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_AnimatorOption_SetCurve()
int32_t OH_ArkUI_AnimatorOption_SetCurve(ArkUI_AnimatorOption* option, ArkUI_CurveHandle value)
Description
Sets the interpolation curve for the animation of an animator.
NOTE
The springCurve, springMotion, responsiveSpringMotion, interpolatingSpring, and customCurve animation curves are not supported.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| ArkUI_CurveHandle value | Interpolation curve. Default value: ARKUI_CURVE_LINEAR. You are advised to use ARKUI_CURVE_EASE_IN_OUT to obtain a smoother animation effect. If value is set to NULL, the default curve ARKUI_CURVE_LINEAR is used. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_AnimatorOption_SetBegin()
int32_t OH_ArkUI_AnimatorOption_SetBegin(ArkUI_AnimatorOption* option, float value)
Description
Sets the interpolation start point of an animation.
NOTE
This API does not take effect when the animation is a keyframe animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| float value | Interpolation start point of the animation. Value range: (-∞, +∞). |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_AnimatorOption_SetEnd()
int32_t OH_ArkUI_AnimatorOption_SetEnd(ArkUI_AnimatorOption* option, float value)
Description
Sets the interpolation end point for the animation of an animator.
NOTE
This API does not take effect when the animation is a keyframe animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| float value | Interpolation end point of the animation. Value range: (-∞, +∞). |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_AnimatorOption_SetExpectedFrameRateRange()
int32_t OH_ArkUI_AnimatorOption_SetExpectedFrameRateRange(ArkUI_AnimatorOption* option, ArkUI_ExpectedFrameRateRange* value)
Description
Sets the expected frame rate range of an animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| ArkUI_ExpectedFrameRateRange* value | Expected frame rate range. If value is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_AnimatorOption_SetKeyframe()
int32_t OH_ArkUI_AnimatorOption_SetKeyframe(ArkUI_AnimatorOption* option, float time, float value, int32_t index)
Description
Sets the keyframe parameters of an animator animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| float time | Keyframe time. Value range: [0, 1]. The value must be in ascending order. Default value: evenly distributed by index (for example, 0.0 for the first frame, 0.5 for the second frame, and 1.0 for the third frame). If the value of time is less than 0 or greater than 1, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| float value | Keyframe value. Value range: (-∞, +∞). |
| int32_t index | Keyframe index. If the value of index is less than 0, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_AnimatorOption_SetKeyframeCurve()
int32_t OH_ArkUI_AnimatorOption_SetKeyframeCurve(ArkUI_AnimatorOption* option, ArkUI_CurveHandle value, int32_t index)
Description
Sets the keyframe curve type for the animation of an animator.
NOTE
The springCurve, springMotion, responsiveSpringMotion, interpolatingSpring, and customCurve animation curves are not supported.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. If option is set to NULL, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
| ArkUI_CurveHandle value | Interpolation curve. Default value: NULL, indicating linear interpolation. |
| int32_t index | Keyframe index. If the value of index is less than 0, the error code ARKUI_ERROR_CODE_PARAM_INVALID is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_AnimatorOption_GetDuration()
int32_t OH_ArkUI_AnimatorOption_GetDuration(ArkUI_AnimatorOption* option)
Description
Obtains the duration for playing an animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator animation parameters. If option is set to NULL, 0 is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Duration for playing the animation, in milliseconds. If option is invalid, 0 is returned. |
OH_ArkUI_AnimatorOption_GetDelay()
int32_t OH_ArkUI_AnimatorOption_GetDelay(ArkUI_AnimatorOption* option)
Description
Obtains the delay for playing an animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator animation parameters. If option is set to NULL, 0 is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Delay for playing the animation, in milliseconds. If option is invalid, 0 is returned. |
OH_ArkUI_AnimatorOption_GetIterations()
int32_t OH_ArkUI_AnimatorOption_GetIterations(ArkUI_AnimatorOption* option)
Description
Obtains the number of times that an animator animation is played.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. If option is set to NULL, 0 is returned. |
Return value
| Type | Description |
|---|---|
| int32_t | Number of times that the animation is played. If option is invalid, 0 is returned. |
OH_ArkUI_AnimatorOption_GetFill()
ArkUI_AnimationFillMode OH_ArkUI_AnimatorOption_GetFill(ArkUI_AnimatorOption* option)
Description
Obtains the status of the component before and after the animator animation execution.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator animation parameters. |
Return value
| Type | Description |
|---|---|
| ArkUI_AnimationFillMode | Status of the component before and after the animator animation execution. If option is invalid,-1 is returned. |
OH_ArkUI_AnimatorOption_GetDirection()
ArkUI_AnimationDirection OH_ArkUI_AnimatorOption_GetDirection(ArkUI_AnimatorOption* option)
Description
Obtains the playback direction of an animator animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator animation parameters. |
Return value
| Type | Description |
|---|---|
| ArkUI_AnimationDirection | Animation playback direction. If option is invalid,-1 is returned. |
OH_ArkUI_AnimatorOption_GetCurve()
ArkUI_CurveHandle OH_ArkUI_AnimatorOption_GetCurve(ArkUI_AnimatorOption* option)
Description
Obtains the interpolation curve of the animation of an animator.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator animation parameters. |
Return value
| Type | Description |
|---|---|
| ArkUI_CurveHandle | Interpolation curve. If option is invalid, NULL is returned. |
OH_ArkUI_AnimatorOption_GetBegin()
float OH_ArkUI_AnimatorOption_GetBegin(ArkUI_AnimatorOption* option)
Description
Obtains the interpolation start point of an animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator animation parameters. |
Return value
| Type | Description |
|---|---|
| float | Interpolation start point of the animation. If option is invalid, 0.0 is returned. |
OH_ArkUI_AnimatorOption_GetEnd()
float OH_ArkUI_AnimatorOption_GetEnd(ArkUI_AnimatorOption* option)
Description
Obtains the interpolation end point of an animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator animation parameters. |
Return value
| Type | Description |
|---|---|
| float | Interpolation end point of the animation. If option is invalid, 0.0 is returned. |
OH_ArkUI_AnimatorOption_GetExpectedFrameRateRange()
ArkUI_ExpectedFrameRateRange* OH_ArkUI_AnimatorOption_GetExpectedFrameRateRange(ArkUI_AnimatorOption* option)
Description
Obtains the expected frame rate range of an animator animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator animation parameters. |
Return value
| Type | Description |
|---|---|
| ArkUI_ExpectedFrameRateRange* | Pointer to the expected frame rate range object. Returns NULL if a parameter error occurs. |
OH_ArkUI_AnimatorOption_GetKeyframeTime()
float OH_ArkUI_AnimatorOption_GetKeyframeTime(ArkUI_AnimatorOption* option, int32_t index)
Description
Obtains the keyframe time of the animator playback, in milliseconds.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. |
| int32_t index | Keyframe index. |
Return value
| Type | Description |
|---|---|
| float | Keyframe time, in milliseconds. |
OH_ArkUI_AnimatorOption_GetKeyframeValue()
float OH_ArkUI_AnimatorOption_GetKeyframeValue(ArkUI_AnimatorOption* option, int32_t index)
Description
Obtains the keyframe value of an animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. |
| int32_t index | Keyframe index. |
Return value
| Type | Description |
|---|---|
| float | Keyframe value. |
OH_ArkUI_AnimatorOption_GetKeyframeCurve()
ArkUI_CurveHandle OH_ArkUI_AnimatorOption_GetKeyframeCurve(ArkUI_AnimatorOption* option, int32_t index)
Description
Obtains the interpolation curve for a keyframe in the animation of an animator.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator parameters. |
| int32_t index | Keyframe index. |
Return value
| Type | Description |
|---|---|
| ArkUI_CurveHandle | Interpolation curve. Returns NULL if a parameter error occurs. |
OH_ArkUI_AnimatorEvent_GetUserData()
void* OH_ArkUI_AnimatorEvent_GetUserData(ArkUI_AnimatorEvent* event)
Description
Obtains the user-defined object in an animation event object.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorEvent* event | Animation event object. |
Return value
| Type | Description |
|---|---|
| void* | User-defined object. |
OH_ArkUI_AnimatorOnFrameEvent_GetUserData()
void* OH_ArkUI_AnimatorOnFrameEvent_GetUserData(ArkUI_AnimatorOnFrameEvent* event)
Description
Obtains the user-defined object in the frame event of an animation.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOnFrameEvent* event | Animation event object. |
Return value
| Type | Description |
|---|---|
| void* | User-defined object. |
OH_ArkUI_AnimatorOnFrameEvent_GetValue()
float OH_ArkUI_AnimatorOnFrameEvent_GetValue(ArkUI_AnimatorOnFrameEvent* event)
Description
Obtains the interpolation result in the animation frame callback event object.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOnFrameEvent* event | Animation event object. |
Return value
| Type | Description |
|---|---|
| float | Animation interpolation result. NOTE During the animation, the interpolation result changes between the interpolation start point OH_ArkUI_AnimatorOption_SetBegin and the interpolation end point OH_ArkUI_AnimatorOption_SetEnd based on the animation parameters. |
OH_ArkUI_AnimatorOption_RegisterOnFrameCallback()
int32_t OH_ArkUI_AnimatorOption_RegisterOnFrameCallback(ArkUI_AnimatorOption* option, void* userData, void (*callback)(ArkUI_AnimatorOnFrameEvent* event))
Description
Sets the callback invoked when the animator receives a frame.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator animation parameters. |
| void* userData | User-defined parameter. |
| void (*callback)(ArkUI_AnimatorOnFrameEvent* event) | Callback function. - event: input parameter of the callback function, an animation event object. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_AnimatorOption_RegisterOnFinishCallback()
int32_t OH_ArkUI_AnimatorOption_RegisterOnFinishCallback(ArkUI_AnimatorOption* option, void* userData, void (*callback)(ArkUI_AnimatorEvent* event))
Description
Sets the callback invoked when the animation playback is complete.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator animation parameters. |
| void* userData | User-defined parameter. |
| void (*callback)(ArkUI_AnimatorEvent* event) | Callback function. - event: input parameter of the callback function, an animation event object. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_AnimatorOption_RegisterOnCancelCallback()
int32_t OH_ArkUI_AnimatorOption_RegisterOnCancelCallback(ArkUI_AnimatorOption* option, void* userData, void (*callback)(ArkUI_AnimatorEvent* event))
Description
Sets the callback invoked when the animation playback is canceled.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator animation parameters. |
| void* userData | User-defined parameter. |
| void (*callback)(ArkUI_AnimatorEvent* event) | Callback function. - event: input parameter of the callback function, an animation event object. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_AnimatorOption_RegisterOnRepeatCallback()
int32_t OH_ArkUI_AnimatorOption_RegisterOnRepeatCallback(ArkUI_AnimatorOption* option, void* userData, void (*callback)(ArkUI_AnimatorEvent* event))
Description
Sets the callback invoked when the animation playback is repeated.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorOption* option | Animator animation parameters. |
| void* userData | User-defined parameter. |
| void (*callback)(ArkUI_AnimatorEvent* event) | Callback function. - event: input parameter of the callback function, an animation event object. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_Animator_ResetAnimatorOption()
int32_t OH_ArkUI_Animator_ResetAnimatorOption(ArkUI_AnimatorHandle animatorHandle, ArkUI_AnimatorOption* option)
Description
Resets the animation of an animator.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorHandle animatorHandle | Animator object. |
| ArkUI_AnimatorOption* option | Animator animation parameters. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_Animator_Play()
int32_t OH_ArkUI_Animator_Play(ArkUI_AnimatorHandle animatorHandle)
Description
Starts the animation of an animator.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorHandle animatorHandle | Animator object. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_Animator_Finish()
int32_t OH_ArkUI_Animator_Finish(ArkUI_AnimatorHandle animatorHandle)
Description
Ends the animation of an animator.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorHandle animatorHandle | Animator object. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_Animator_Pause()
int32_t OH_ArkUI_Animator_Pause(ArkUI_AnimatorHandle animatorHandle)
Description
Pauses the animation of an animator.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorHandle animatorHandle | Animator object. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_Animator_Cancel()
int32_t OH_ArkUI_Animator_Cancel(ArkUI_AnimatorHandle animatorHandle)
Description
Cancels the animation of an animator.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorHandle animatorHandle | Animator object. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_Animator_Reverse()
int32_t OH_ArkUI_Animator_Reverse(ArkUI_AnimatorHandle animatorHandle)
Description
Plays this animation in reverse order.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimatorHandle animatorHandle | Animator object. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_Curve_CreateCurveByType()
ArkUI_CurveHandle OH_ArkUI_Curve_CreateCurveByType(ArkUI_AnimationCurve curve)
Description
Implements initialization for the interpolation curve, which is used to create an interpolation curve based on the input parameter.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_AnimationCurve curve | Curve type. |
Return value
| Type | Description |
|---|---|
| ArkUI_CurveHandle | Pointer to the interpolation object of the curve. Returns NULL if a parameter error occurs. |
OH_ArkUI_Curve_CreateStepsCurve()
ArkUI_CurveHandle OH_ArkUI_Curve_CreateStepsCurve(int32_t count, bool end)
Description
Creates a step curve.
Since: 12
Parameters
| Name | Description |
|---|---|
| int32_t count | Number of steps. The value must be a positive integer. Value range: [1, +∞). If the value of count is abnormal, the operation is invalid. |
| bool end | Whether the step change occurs at the start or end of each interval. true: The step change occurs at the end of each interval. false: The step change occurs at the start of each interval. |
Return value
| Type | Description |
|---|---|
| ArkUI_CurveHandle | Pointer to the interpolation object of the curve. Returns NULL if a parameter error occurs. |
OH_ArkUI_Curve_CreateCubicBezierCurve()
ArkUI_CurveHandle OH_ArkUI_Curve_CreateCubicBezierCurve(float x1, float y1, float x2, float y2)
Description
Creates a cubic Bezier curve.
Since: 12
Parameters
| Name | Description |
|---|---|
| float x1 | X-coordinate of the first point on the Bezier curve. Value range: [0, 1]. A value less than 0 is treated as 0. A value greater than 1 is treated as 1. |
| float y1 | Y-coordinate of the first point on the Bezier curve. |
| float x2 | X-coordinate of the second point on the Bezier curve. Value range: [0, 1]. A value less than 0 is treated as 0. A value greater than 1 is treated as 1. |
| float y2 | Y-coordinate of the second point on the Bezier curve. |
Return value
| Type | Description |
|---|---|
| ArkUI_CurveHandle | Pointer to the interpolation object of the curve. Returns NULL if a parameter error occurs. |
OH_ArkUI_Curve_CreateSpringCurve()
ArkUI_CurveHandle OH_ArkUI_Curve_CreateSpringCurve(float velocity, float mass, float stiffness, float damping)
Description
Creates a spring curve. The curve shape is determined by the spring parameters, and the animation duration is controlled by the duration parameter in animation and animateTo.
Since: 12
Parameters
| Name | Description |
|---|---|
| float velocity | Initial velocity. It is applied by external factors to the spring animation, designed to help ensure the smooth transition from the previous motion state. The velocity is the normalized velocity, and its value is equal to the actual velocity at the beginning of the animation divided by the animation attribute change value. |
| float mass | Mass. It describes the inertia of the object in the elastic system, affecting the amplitude of oscillation and the speed of return to equilibrium. The greater the mass, the greater the amplitude of the oscillation, and the slower the speed of restoring to the equilibrium position. Value range: [0, +∞). If the value is less than or equal to 0, 1 is used. |
| float stiffness | Stiffness. It is the degree to which an object deforms by resisting the force applied. In an elastic system, the greater the stiffness, the stronger the ability to resist deformation, and the faster the speed of restoring to the equilibrium position. Value range: [0, +∞). If the value is less than or equal to 0, 1 is used. |
| float damping | Damping. It is used to describe the oscillation and attenuation of the system after being disturbed. The larger the damping, the smaller the number of oscillations of elastic motion, and the smaller the oscillation amplitude. Value range: [0, +∞). If the value is less than or equal to 0, 1 is used. |
Return value
| Type | Description |
|---|---|
| ArkUI_CurveHandle | Pointer to the interpolation object of the curve. Returns NULL if a parameter error occurs. |
OH_ArkUI_Curve_CreateSpringMotion()
ArkUI_CurveHandle OH_ArkUI_Curve_CreateSpringMotion(float response, float dampingFraction, float overlapDuration)
Description
Creates a spring animation curve. If multiple spring animations are applied to the same attribute of an object, each animation replaces their predecessor and inherits the velocity.
NOTE
The animation duration determined by the curve parameters, rather than the duration parameter in animation or animateTo.
Since: 12
Parameters
| Name | Description |
|---|---|
| float response | Duration of one complete oscillation. Value range: (0, +∞). If the value is less than or equal to 0, 0.55 is used. |
| float dampingFraction | Damping coefficient. > 0 and < 1: underdamped. In this case, the spring overshoots the equilibrium position. 1: critically damped. > 1: overdamped. In this case, the spring approaches equilibrium gradually. Value range: (0, +∞). If the value is less than or equal to 0, 0.825 is used. |
| float overlapDuration | Duration for animations to overlap, in seconds. When animations overlap, the response values of these animations will transit smoothly over this duration if they are different. Value range: [0, +∞). If the value is less than 0, 0 is used. |
Return value
| Type | Description |
|---|---|
| ArkUI_CurveHandle | Pointer to the interpolation object of the curve. Returns NULL if a parameter error occurs. |
OH_ArkUI_Curve_CreateResponsiveSpringMotion()
ArkUI_CurveHandle OH_ArkUI_Curve_CreateResponsiveSpringMotion(float response, float dampingFraction, float overlapDuration)
Description
Creates a responsive spring animation curve. It is a special case of springMotion, with the only difference in the default values. It can be used together with springMotion.
NOTE
The animation duration determined by the curve parameters, rather than the duration parameter in animation or animateTo.
Since: 12
Parameters
| Name | Description |
|---|---|
| float response | Duration of one complete oscillation. Value range: (0, +∞). If the value is less than or equal to 0, 0.15 is used. |
| float dampingFraction | Damping coefficient. > 0 and < 1: underdamped. In this case, the spring overshoots the equilibrium position. 1: critically damped. > 1: overdamped. In this case, the spring approaches equilibrium gradually. Value range: [0, +∞). If the value is less than 0, 0.86 is used. |
| float overlapDuration | Duration for animations to overlap, in seconds. When animations overlap, the response values of these animations will transit smoothly over this duration if they are different. Value range: [0, +∞). If the value is less than 0, 0.25 is used. |
Return value
| Type | Description |
|---|---|
| ArkUI_CurveHandle | Pointer to the interpolation object of the curve. Returns NULL if a parameter error occurs. |
OH_ArkUI_Curve_CreateInterpolatingSpring()
ArkUI_CurveHandle OH_ArkUI_Curve_CreateInterpolatingSpring(float velocity, float mass, float stiffness, float damping)
Description
Creates an interpolating spring curve animated from 0 to 1. The actual animation value is calculated based on the curve.
NOTE
The animation duration determined by the curve parameters, rather than the duration parameter in animation or animateTo.
Since: 12
Parameters
| Name | Description |
|---|---|
| float velocity | Initial velocity. It is applied by external factors to the spring animation, designed to help ensure the smooth transition from the previous motion state. The velocity is the normalized velocity, and its value is equal to the actual velocity at the beginning of the animation divided by the animation attribute change value. |
| float mass | Mass. It describes the inertia of the object in the elastic system, affecting the amplitude of oscillation and the speed of return to equilibrium. The greater the mass, the greater the amplitude of the oscillation, and the slower the speed of restoring to the equilibrium position. Value range: [0, +∞). If the value is less than or equal to 0, 1 is used. |
| float stiffness | Stiffness. It is the degree to which an object deforms by resisting the force applied. The greater the stiffness, the stronger the ability to resist deformation, and the faster the speed of restoring to the equilibrium position. Value range: [0, +∞). If the value is less than or equal to 0, 1 is used. |
| float damping | Damping. It is used to describe the oscillation and attenuation of the system after being disturbed. The larger the damping, the smaller the number of oscillations of elastic motion, and the smaller the oscillation amplitude. Value range: [0, +∞). If the value is less than or equal to 0, 1 is used. |
Return value
| Type | Description |
|---|---|
| ArkUI_CurveHandle | Pointer to the interpolation object of the curve. Returns NULL if a parameter error occurs. |
OH_ArkUI_Curve_CreateCustomCurve()
ArkUI_CurveHandle OH_ArkUI_Curve_CreateCustomCurve(void* userData, float (*interpolate)(float fraction, void* userdata))
Description
Creates a custom curve.
Since: 12
Parameters
| Name | Description |
|---|---|
| void* userData | Pointer to user-defined data. |
| float (*interpolate)(float fraction, void* userdata) | User-defined interpolation callback. fraction indicates the input x value for interpolation when the animation starts; value range: [0, 1]. The return value is the y value of the curve. value range: [0, 1]. If fraction is 0, the return value 0 corresponds to the animation start point; any other return value means that the animation jumps at the start point. If fraction is 1, the return value 1 corresponds to the animation end point; any other return value means that the end value of the animation is not the value of the state variable, which will result in an effect of transition from that end value to the value of the state variable. |
Return value
| Type | Description |
|---|---|
| ArkUI_CurveHandle | Pointer to the interpolation object of the curve. Returns NULL if a parameter error occurs. |
OH_ArkUI_Curve_DisposeCurve()
void OH_ArkUI_Curve_DisposeCurve(ArkUI_CurveHandle curveHandle)
Description
Disposes of a custom curve.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_CurveHandle curveHandle | Pointer to the interpolation object of the curve. |
OH_ArkUI_CreateOpacityTransitionEffect()
ArkUI_TransitionEffect* OH_ArkUI_CreateOpacityTransitionEffect(float opacity)
Description
Creates an opacity effect object for component transitions.
Since: 12
Parameters
| Name | Description |
|---|---|
| float opacity | Opacity. Value range: [0, 1]. The default value is 1. A value less than 0 is treated as 0. A value greater than 1 is treated as 1. The value 1 means fully opaque, and 0 means fully transparent. |
Return value
| Type | Description |
|---|---|
| ArkUI_TransitionEffect* | Opacity effect object for component transitions. |
OH_ArkUI_CreateTranslationTransitionEffect()
ArkUI_TransitionEffect* OH_ArkUI_CreateTranslationTransitionEffect(ArkUI_TranslationOptions* translate)
Description
Creates a translation effect object for component transitions.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_TranslationOptions* translate | Translation parameter object for component transitions. |
Return value
| Type | Description |
|---|---|
| ArkUI_TransitionEffect* | Translation effect object for component transitions. Returns NULL if a parameter error occurs. |
OH_ArkUI_CreateScaleTransitionEffect()
ArkUI_TransitionEffect* OH_ArkUI_CreateScaleTransitionEffect(ArkUI_ScaleOptions* scale)
Description
Creates a scaling effect object for component transitions.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_ScaleOptions* scale | Scaling parameter object for component transitions. |
Return value
| Type | Description |
|---|---|
| ArkUI_TransitionEffect* | Scaling effect object for component transitions. Returns NULL if a parameter error occurs. |
OH_ArkUI_CreateRotationTransitionEffect()
ArkUI_TransitionEffect* OH_ArkUI_CreateRotationTransitionEffect(ArkUI_RotationOptions* rotate)
Description
Creates a rotation effect object for component transition.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_RotationOptions* rotate | Rotation parameter object for component transitions. |
Return value
| Type | Description |
|---|---|
| ArkUI_TransitionEffect* | Rotation effect object for component transitions. Returns NULL if a parameter error occurs. |
OH_ArkUI_CreateMovementTransitionEffect()
ArkUI_TransitionEffect* OH_ArkUI_CreateMovementTransitionEffect(ArkUI_TransitionEdge edge)
Description
Creates a movement transition effect object for the component.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_TransitionEdge edge | Movement transition type. |
Return value
| Type | Description |
|---|---|
| ArkUI_TransitionEffect* | Translation effect object for component transitions. Returns NULL if a parameter error occurs. |
OH_ArkUI_CreateAsymmetricTransitionEffect()
ArkUI_TransitionEffect* OH_ArkUI_CreateAsymmetricTransitionEffect(ArkUI_TransitionEffect* appear, ArkUI_TransitionEffect* disappear)
Description
Creates an asymmetric transition effect.
NOTE
If this function is not used for ArkUI_TransitionEffect, the transition effect takes effect for both appearance and disappearance of the component.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_TransitionEffect* appear | Transition effect for appearance. |
| ArkUI_TransitionEffect* disappear | Transition effect for disappearance. |
Return value
| Type | Description |
|---|---|
| ArkUI_TransitionEffect* | Asymmetric transition effect. Returns NULL if a parameter error occurs. |
OH_ArkUI_TransitionEffect_Dispose()
void OH_ArkUI_TransitionEffect_Dispose(ArkUI_TransitionEffect* effect)
Description
Disposes of a transition effect.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_TransitionEffect* effect | Pointer to the transition effect to be disposed. |
OH_ArkUI_TransitionEffect_Combine()
int32_t OH_ArkUI_TransitionEffect_Combine(ArkUI_TransitionEffect* firstEffect, ArkUI_TransitionEffect* secondEffect)
Description
Sets a combination of transition effects.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_TransitionEffect* firstEffect | Transition effect. |
| ArkUI_TransitionEffect* secondEffect | Combination of transition effects. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
OH_ArkUI_TransitionEffect_SetAnimation()
int32_t OH_ArkUI_TransitionEffect_SetAnimation(ArkUI_TransitionEffect* effect, ArkUI_AnimateOption* animation)
Description
Sets transition effect animation settings.
NOTE
If OH_ArkUI_TransitionEffect_Combine is used to combine transition effects, the animation parameter settings of a transition effect are applicable to the one following it.
Since: 12
Parameters
| Name | Description |
|---|---|
| ArkUI_TransitionEffect* effect | Transition effect. |
| ArkUI_AnimateOption* animation | Animation settings. |
Return value
| Type | Description |
|---|---|
| int32_t | Result code. Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs. |
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 arkts-apis-uicontext-contextmenucontroller
openharmony 鸿蒙 errorcode-canvas
openharmony 鸿蒙 capi-oh-nativexcomponent-native-xcomponent-oh-nativexcomponent
openharmony 鸿蒙 errorcode-bindSheet
openharmony 鸿蒙 js-apis-arkui-uiExtension-sys
openharmony 鸿蒙 capi-arkui-accessibility-arkui-accessibilityeventinfo
openharmony 鸿蒙 capi-arkui-rendernodeutils
openharmony 鸿蒙 js-apis-arkui-node
openharmony 鸿蒙 capi-native-node-h
openharmony 鸿蒙 capi-arkui-nativemodule-arkui-listitemswipeactionitem