說明:從 API Version 7 開始支持。后續版本如有新增內容,則采用上角標單獨標記該內容的起始版本。
導入模塊:
import curves from ‘@ohos.curves’
curves.init
init(curve?: Curve): Object
插值曲線的初始化函數,可以根據入參創建一個插值曲線對象。
參數:

返回值:
曲線對象Object。
curves.steps
steps(count: number, end: boolean): Object
構造階梯曲線對象。
參數:

返回值:
曲線對象Object。
curves.cubicBezier
cubicBezier(x1: number, y1: number, x2: number, y2: number): Object
構造三階貝塞爾曲線對象,曲線的值必須處于0-1之間。
參數:

返回值:
曲線對象Object。
curves.spring
spring(velocity: number, mass: number, stiffness: number, damping: number): Object
構造彈簧曲線對象。
參數:

返回值:
曲線對象Object。
示例:
import Curves from '@ohos.curves'
@Entry
@Component
struct ImageComponent {
@State widthSize: number = 200
@State heightSize: number = 200
build() {
Column() {
Text()
.margin({top:100})
.width(this.widthSize)
.height(this.heightSize)
.backgroundColor(Color.Red)
.onClick(()=> {
let curve = Curves.cubicBezier(0.25, 0.1, 0.25, 1.0);
this.widthSize = curve.interpolate(0.5) * this.widthSize;
this.heightSize = curve.interpolate(0.5) * this.heightSize;
})
.animation({duration: 2000 , curve: Curves.spring(0.25, 0.1, 0.25, 1.0)})
}.width("100%").height("100%")
}
}
復制
審核編輯:湯梓紅
-
計算
+關注
關注
2文章
460瀏覽量
39999 -
曲線
+關注
關注
1文章
82瀏覽量
21452 -
HarmonyOS
+關注
關注
80文章
2153瀏覽量
36055
發布評論請先 登錄
神經網絡加速器的雙線性插值上采樣
QCon·上海站HarmonyOS開發者技術分論壇:共探鴻蒙開發新機遇
【EASY EAI Orin Nano開發板試用體驗】使用和LVGL的anim(簡易動畫)和animimg(圖像動畫)控件組合實現復雜的動畫功能
【HarmonyOS 5】金融應用開發鴻蒙組件實踐
【 HarmonyOS 5 入門系列 】鴻蒙HarmonyOS示例項目講解
bindsheet+鍵盤在頁面跳轉時的bug及處理思路
【HarmonyOS next】ArkUI-X休閑益智記憶翻牌【進階】
【HarmonyOS next】ArkUI-X休閑益智消消樂【進階】
【HarmonyOS next】ArkUI-X休閑益智兒童拼圖【進階】
HarmonyOS入門指南
華為正式啟動HarmonyOS 6開發者Beta
HarmonyOS 代碼工坊的指尖開發,讓 APP 開發所見即所得
HarmonyOS應用開發TS動畫插值計算體驗
評論