说明:从 API Version 7 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
导入模块:
import curves from ‘@ohos.curves’
curves.init
init(curve?: Curve): Object
插值曲线的初始化函数,可以根据入参创建一个插值曲线对象。
参数:
返回值:曲线对象Object。
curves.stepssteps(count: number, end: boolean): Object构造阶梯曲线对象。参数:
返回值:曲线对象Object。
curves.cubicBeziercubicBezier(x1: number, y1: number, x2: number, y2: number): Object构造三阶贝塞尔曲线对象,曲线的值必须处于0-1之间。参数:
返回值:曲线对象Object。
curves.springspring(velocity: number, mass: number, stiffness: number, damping: number): Object构造弹簧曲线对象。参数:
返回值:曲线对象Object。
示例:
import Curves from \'@ohos.curves\'@Entry@Componentstruct 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%\") }}
复制
审核编辑:汤梓红
<!–