• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "frameworks/bridge/declarative_frontend/engine/jsi/modules/jsi_curves_module.h"
17 
18 #include "base/json/json_util.h"
19 #include "base/log/log.h"
20 #include "frameworks/bridge/common/utils/utils.h"
21 #include "frameworks/bridge/declarative_frontend/engine/jsi/jsi_declarative_engine.h"
22 #include "frameworks/bridge/js_frontend/engine/common/js_constants.h"
23 #include "frameworks/core/animation/curve.h"
24 #include "frameworks/core/common/container.h"
25 
26 namespace OHOS::Ace::Framework {
27 
CurvesInterpolate(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc)28 shared_ptr<JsValue> CurvesInterpolate(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
29     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc)
30 {
31     auto jsCurveString = thisObj->GetProperty(runtime, "__curveString");
32     auto curveString = jsCurveString->ToString(runtime);
33     auto curveObjFunc = thisObj->GetProperty(runtime, "__curveCustomFunc");
34     if (argv.size() == 0) {
35         return runtime->NewNull();
36     }
37     double time = argv[0]->ToDouble(runtime);
38     time = std::clamp(time, 0.0, 1.0);
39     auto animationCurve = CreateCurve(curveString, false);
40     if (curveObjFunc->IsFunction(runtime)) {
41         std::function<float(float)> customCallBack = [func = std::move(curveObjFunc),
42                     id = Container::CurrentId(), runtime] (float time)->float {
43                     ContainerScope scope(id);
44                     std::vector<shared_ptr<JsValue>> argv = { runtime->NewNumber(time) };
45                     auto result = func->Call(runtime, runtime->GetGlobal(), argv, 1);
46                     return result->IsNumber(runtime) ? static_cast<float>(result->ToDouble(runtime)) : 1.0f;
47                 };
48         animationCurve = CreateCurve(customCallBack);
49     }
50     if (!animationCurve) {
51         LOGW("created animationCurve is null, curveString:%{public}s", curveString.c_str());
52         return runtime->NewNull();
53     }
54     double curveValue = animationCurve->Move(time);
55     return runtime->NewNumber(curveValue);
56 }
57 
CurvesInitInternal(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc)58 shared_ptr<JsValue> CurvesInitInternal(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
59     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc)
60 {
61     auto curveObj = runtime->NewObject();
62     curveObj->SetProperty(runtime, CURVE_INTERPOLATE, runtime->NewFunction(CurvesInterpolate));
63     if (argc != 1 && argc != 0) {
64         LOGE("CurvesInit args count is invalid");
65         return runtime->NewNull();
66     }
67     RefPtr<Curve> curve;
68     std::string curveString;
69     if (argc == 1) {
70         curveString = argv[0]->ToString(runtime);
71     } else {
72         curveString = "linear";
73     }
74     curve = CreateCurve(curveString);
75     curveObj->SetProperty(runtime, "__curveString", runtime->NewString(curveString));
76     if (Container::IsCurrentUseNewPipeline()) {
77         return curveObj;
78     }
79 
80     auto page = JsiDeclarativeEngineInstance::GetStagingPage(Container::CurrentId());
81     int32_t pageId = -1;
82     if (page == nullptr) {
83         LOGW("page is nullptr");
84     } else {
85         pageId = page->GetPageId();
86     }
87     curveObj->SetProperty(runtime, "__pageId", runtime->NewInt32(pageId));
88     return curveObj;
89 }
90 
CurvesInit(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc)91 shared_ptr<JsValue> CurvesInit(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
92     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc)
93 {
94     return CurvesInitInternal(runtime, thisObj, argv, argc);
95 }
96 
InitCurve(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc)97 shared_ptr<JsValue> InitCurve(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
98     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc)
99 {
100     return CurvesInitInternal(runtime, thisObj, argv, argc);
101 }
102 
CreateSpringCurve(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc,RefPtr<Curve> & curve)103 bool CreateSpringCurve(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
104     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc, RefPtr<Curve>& curve)
105 {
106     if (argc != 4) {
107         LOGE("Spring curve: the number of parameters is illegal");
108         return false;
109     }
110     double velocity = argv[0]->ToDouble(runtime);
111     double mass = argv[1]->ToDouble(runtime);
112     double stiffness = argv[2]->ToDouble(runtime);
113     double damping = argv[3]->ToDouble(runtime);
114     if (LessNotEqual(mass, 0)) {
115         LOGW("Spring curve: mass is illegal, value:%{public}f, use default", mass);
116         mass = 1.0;
117     }
118     if (LessNotEqual(stiffness, 0)) {
119         LOGW("Spring curve: stiffness is illegal, value:%{public}f, use default", stiffness);
120         stiffness = 1.0;
121     }
122     if (LessNotEqual(damping, 0)) {
123         LOGW("Spring curve: damping is illegal, value:%{public}f, use default", damping);
124         damping = 1.0;
125     }
126     curve = AceType::MakeRefPtr<SpringCurve>(velocity, mass, stiffness, damping);
127     return true;
128 }
129 
CreateInterpolatingSpring(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc,RefPtr<Curve> & curve)130 bool CreateInterpolatingSpring(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
131     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc, RefPtr<Curve>& curve)
132 {
133     if (argc != 4) {
134         LOGE("interpolating Spring: the number of parameters is illegal");
135         return false;
136     }
137     float velocity = static_cast<float>(argv[0]->ToDouble(runtime));
138     float mass = static_cast<float>(argv[1]->ToDouble(runtime));
139     float stiffness = static_cast<float>(argv[2]->ToDouble(runtime));
140     float damping = static_cast<float>(argv[3]->ToDouble(runtime));
141     if (LessNotEqual(mass, 0)) {
142         LOGW("interpolating Spring: mass is illegal, value:%{public}f, use default", mass);
143         mass = 1.0;
144     }
145     if (LessNotEqual(stiffness, 0)) {
146         LOGW("interpolating Spring: stiffness is illegal, value:%{public}f, use default", stiffness);
147         stiffness = 1.0;
148     }
149     if (LessNotEqual(damping, 0)) {
150         LOGW("interpolating Spring: damping is illegal, value:%{public}f, use default", damping);
151         damping = 1.0;
152     }
153     curve = AceType::MakeRefPtr<InterpolatingSpring>(velocity, mass, stiffness, damping);
154     return true;
155 }
156 
CreateCubicCurve(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc,RefPtr<Curve> & curve)157 bool CreateCubicCurve(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
158     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc, RefPtr<Curve>& curve)
159 {
160     if (argc != 4) {
161         LOGE("Cubic curve: the number of parameters is illegal");
162         return false;
163     }
164     double x0 = argv[0]->ToDouble(runtime);
165     double y0 = argv[1]->ToDouble(runtime);
166     double x1 = argv[2]->ToDouble(runtime);
167     double y1 = argv[3]->ToDouble(runtime);
168     x0 = std::clamp(x0, 0.0, 1.0);
169     x1 = std::clamp(x1, 0.0, 1.0);
170 
171     curve = AceType::MakeRefPtr<CubicCurve>(x0, y0, x1, y1);
172     return true;
173 }
174 
CreateStepsCurve(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc,RefPtr<Curve> & curve)175 bool CreateStepsCurve(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
176     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc, RefPtr<Curve>& curve)
177 {
178     if (argc != 1 && argc != 2) {
179         LOGE("Steps curve: the number of parameters is illegal");
180         return false;
181     }
182     int32_t stepSize = 1;
183     if (argv[0]->IsNumber(runtime)) {
184         stepSize = argv[0]->ToInt32(runtime);
185         if (stepSize < 1) {
186             LOGW("Steps curve: the value of the stepSize is illegal, use default value");
187             stepSize = 1;
188         }
189     }
190     if (argc == 2) {
191         bool isEnd = argv[1]->ToBoolean(runtime);
192         if (isEnd) {
193             curve = AceType::MakeRefPtr<StepsCurve>(stepSize, StepsCurvePosition::END);
194         } else {
195             curve = AceType::MakeRefPtr<StepsCurve>(stepSize, StepsCurvePosition::START);
196         }
197     } else {
198         curve = AceType::MakeRefPtr<StepsCurve>(stepSize);
199     }
200     return true;
201 }
202 
CreateSpringMotionCurve(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc,RefPtr<Curve> & curve)203 bool CreateSpringMotionCurve(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
204     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc, RefPtr<Curve>& curve)
205 {
206     if (argc > 3) {
207         LOGW("SpringMotionCurve: the number of parameters is illegal");
208         return false;
209     }
210     float response = ResponsiveSpringMotion::DEFAULT_SPRING_MOTION_RESPONSE;
211     float dampingRatio = ResponsiveSpringMotion::DEFAULT_SPRING_MOTION_DAMPING_RATIO;
212     float blendDuration = ResponsiveSpringMotion::DEFAULT_SPRING_MOTION_BLEND_DURATION;
213     if (argc > 0) {
214         response = static_cast<float>(argv[0]->ToDouble(runtime));
215         if (LessNotEqual(response, 0)) {
216             response = ResponsiveSpringMotion::DEFAULT_SPRING_MOTION_RESPONSE;
217             LOGW("SpringMotion: response is illegal, use default value:%{public}f", response);
218         }
219     }
220     if (argc > 1) {
221         dampingRatio = static_cast<float>(argv[1]->ToDouble(runtime));
222         if (LessNotEqual(dampingRatio, 0)) {
223             dampingRatio = ResponsiveSpringMotion::DEFAULT_SPRING_MOTION_DAMPING_RATIO;
224             LOGW("SpringMotion: dampingRatio is illegal, use default value:%{public}f", dampingRatio);
225         }
226     }
227     if (argc > 2) {
228         blendDuration = static_cast<float>(argv[2]->ToDouble(runtime));
229         if (LessNotEqual(blendDuration, 0)) {
230             blendDuration = ResponsiveSpringMotion::DEFAULT_SPRING_MOTION_BLEND_DURATION;
231             LOGW("SpringMotion: blendDuration is illegal, use default value:%{public}f", blendDuration);
232         }
233     }
234     curve = AceType::MakeRefPtr<ResponsiveSpringMotion>(response, dampingRatio, blendDuration);
235     return true;
236 }
237 
CreateResponsiveSpringMotionCurve(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc,RefPtr<Curve> & curve)238 bool CreateResponsiveSpringMotionCurve(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
239     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc, RefPtr<Curve>& curve)
240 {
241     if (argc > 3) {
242         LOGW("ResponsiveSpringMotionCurve: the number of parameters is illegal");
243         return false;
244     }
245     float response = ResponsiveSpringMotion::DEFAULT_RESPONSIVE_SPRING_MOTION_RESPONSE;
246     float dampingRatio = ResponsiveSpringMotion::DEFAULT_RESPONSIVE_SPRING_MOTION_DAMPING_RATIO;
247     float blendDuration = ResponsiveSpringMotion::DEFAULT_RESPONSIVE_SPRING_MOTION_BLEND_DURATION;
248     if (argc > 0) {
249         response = static_cast<float>(argv[0]->ToDouble(runtime));
250         if (LessNotEqual(response, 0)) {
251             response = ResponsiveSpringMotion::DEFAULT_RESPONSIVE_SPRING_MOTION_RESPONSE;
252             LOGW("ResponsiveSpringMotion: response is illegal, use default value:%{public}f", response);
253         }
254     }
255     if (argc > 1) {
256         dampingRatio = static_cast<float>(argv[1]->ToDouble(runtime));
257         if (LessNotEqual(dampingRatio, 0)) {
258             dampingRatio = ResponsiveSpringMotion::DEFAULT_RESPONSIVE_SPRING_MOTION_DAMPING_RATIO;
259             LOGW("ResponsiveSpringMotion: dampingRatio is illegal, use default value:%{public}f", dampingRatio);
260         }
261     }
262     if (argc > 2) {
263         blendDuration = static_cast<float>(argv[2]->ToDouble(runtime));
264         if (LessNotEqual(blendDuration, 0)) {
265             blendDuration = ResponsiveSpringMotion::DEFAULT_RESPONSIVE_SPRING_MOTION_BLEND_DURATION;
266             LOGW("ResponsiveSpringMotion: blendDuration is illegal, use default value:%{public}f", blendDuration);
267         }
268     }
269     curve = AceType::MakeRefPtr<ResponsiveSpringMotion>(response, dampingRatio, blendDuration);
270     return true;
271 }
272 
ParseCurves(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc,std::string & curveString)273 shared_ptr<JsValue> ParseCurves(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
274     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc, std::string& curveString)
275 {
276     auto curveObj = runtime->NewObject();
277     curveObj->SetProperty(runtime, CURVE_INTERPOLATE, runtime->NewFunction(CurvesInterpolate));
278     RefPtr<Curve> curve;
279     bool curveCreated;
280     if (curveString == CURVES_SPRING || curveString == SPRING_CURVE) {
281         curveCreated = CreateSpringCurve(runtime, thisObj, argv, argc, curve);
282     } else if (curveString == INTERPOLATING_SPRING) {
283         curveCreated = CreateInterpolatingSpring(runtime, thisObj, argv, argc, curve);
284     } else if (curveString == CURVES_CUBIC_BEZIER || curveString == CUBIC_BEZIER_CURVE) {
285         curveCreated = CreateCubicCurve(runtime, thisObj, argv, argc, curve);
286     } else if (curveString == CURVES_STEPS || curveString == STEPS_CURVE) {
287         curveCreated = CreateStepsCurve(runtime, thisObj, argv, argc, curve);
288     } else if (curveString == SPRING_MOTION) {
289         curveCreated = CreateSpringMotionCurve(runtime, thisObj, argv, argc, curve);
290     } else if (curveString == RESPONSIVE_SPRING_MOTION) {
291         curveCreated = CreateResponsiveSpringMotionCurve(runtime, thisObj, argv, argc, curve);
292     } else if (curveString == CURVES_CUSTOM) {
293         curve = AceType::MakeRefPtr<CustomCurve>(nullptr);
294         curveCreated = true;
295         if (argv[0]->IsFunction(runtime)) {
296             curveObj->SetProperty(runtime, "__curveCustomFunc", argv[0]);
297         } else {
298             curveCreated = false;
299             LOGW("customCruve argv is not function argv[0] = %{public}s", argv[0]->ToString(runtime).c_str());
300         }
301     } else {
302         LOGE("curve params: %{public}s is illegal", curveString.c_str());
303         return runtime->NewNull();
304     }
305     if (!curveCreated) {
306         return runtime->NewNull();
307     }
308     auto customCurve = curve->ToString();
309     curveObj->SetProperty(runtime, "__curveString", runtime->NewString(customCurve));
310     if (Container::IsCurrentUseNewPipeline()) {
311         return curveObj;
312     }
313     auto page = JsiDeclarativeEngineInstance::GetStagingPage(Container::CurrentId());
314     int32_t pageId = -1;
315     if (page == nullptr) {
316         LOGW("page is nullptr");
317     } else {
318         pageId = page->GetPageId();
319     }
320     curveObj->SetProperty(runtime, "__pageId", runtime->NewInt32(pageId));
321     return curveObj;
322 }
323 
CurvesBezier(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc)324 shared_ptr<JsValue> CurvesBezier(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
325     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc)
326 {
327     std::string curveString(CURVES_CUBIC_BEZIER);
328     return ParseCurves(runtime, thisObj, argv, argc, curveString);
329 }
330 
BezierCurve(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc)331 shared_ptr<JsValue> BezierCurve(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
332     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc)
333 {
334     std::string curveString(CUBIC_BEZIER_CURVE);
335     return ParseCurves(runtime, thisObj, argv, argc, curveString);
336 }
337 
CurvesSpring(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc)338 shared_ptr<JsValue> CurvesSpring(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
339     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc)
340 {
341     std::string curveString(CURVES_SPRING);
342     return ParseCurves(runtime, thisObj, argv, argc, curveString);
343 }
344 
SpringCurve(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc)345 shared_ptr<JsValue> SpringCurve(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
346     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc)
347 {
348     std::string curveString(SPRING_CURVE);
349     return ParseCurves(runtime, thisObj, argv, argc, curveString);
350 }
351 
InterpolatingSpringCurve(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc)352 shared_ptr<JsValue> InterpolatingSpringCurve(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
353     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc)
354 {
355     std::string curveString(INTERPOLATING_SPRING);
356     return ParseCurves(runtime, thisObj, argv, argc, curveString);
357 }
358 
CurvesSteps(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc)359 shared_ptr<JsValue> CurvesSteps(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
360     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc)
361 {
362     std::string curveString(CURVES_STEPS);
363     return ParseCurves(runtime, thisObj, argv, argc, curveString);
364 }
365 
StepsCurve(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc)366 shared_ptr<JsValue> StepsCurve(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
367     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc)
368 {
369     std::string curveString(STEPS_CURVE);
370     return ParseCurves(runtime, thisObj, argv, argc, curveString);
371 }
CustomCurve(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc)372 shared_ptr<JsValue> CustomCurve(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
373     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc)
374 {
375     std::string curveString(CURVES_CUSTOM);
376     return ParseCurves(runtime, thisObj, argv, argc, curveString);
377 }
378 
SpringMotionCurve(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc)379 shared_ptr<JsValue> SpringMotionCurve(const shared_ptr<JsRuntime>& runtime, const shared_ptr<JsValue>& thisObj,
380     const std::vector<shared_ptr<JsValue>>& argv, int32_t argc)
381 {
382     std::string curveString(SPRING_MOTION);
383     return ParseCurves(runtime, thisObj, argv, argc, curveString);
384 }
385 
ResponsiveSpringMotionCurve(const shared_ptr<JsRuntime> & runtime,const shared_ptr<JsValue> & thisObj,const std::vector<shared_ptr<JsValue>> & argv,int32_t argc)386 shared_ptr<JsValue> ResponsiveSpringMotionCurve(const shared_ptr<JsRuntime>& runtime,
387     const shared_ptr<JsValue>& thisObj, const std::vector<shared_ptr<JsValue>>& argv, int32_t argc)
388 {
389     std::string curveString(RESPONSIVE_SPRING_MOTION);
390     return ParseCurves(runtime, thisObj, argv, argc, curveString);
391 }
392 
InitCurvesModule(const shared_ptr<JsRuntime> & runtime,shared_ptr<JsValue> & moduleObj)393 void InitCurvesModule(const shared_ptr<JsRuntime>& runtime, shared_ptr<JsValue>& moduleObj)
394 {
395     moduleObj->SetProperty(runtime, CURVES_INIT, runtime->NewFunction(CurvesInit));
396     moduleObj->SetProperty(runtime, INIT_CURVE, runtime->NewFunction(InitCurve));
397     moduleObj->SetProperty(runtime, CURVES_CUBIC_BEZIER, runtime->NewFunction(CurvesBezier));
398     moduleObj->SetProperty(runtime, CUBIC_BEZIER_CURVE, runtime->NewFunction(BezierCurve));
399     moduleObj->SetProperty(runtime, CURVES_SPRING, runtime->NewFunction(CurvesSpring));
400     moduleObj->SetProperty(runtime, SPRING_CURVE, runtime->NewFunction(SpringCurve));
401     moduleObj->SetProperty(runtime, INTERPOLATING_SPRING, runtime->NewFunction(InterpolatingSpringCurve));
402     moduleObj->SetProperty(runtime, CURVES_STEPS, runtime->NewFunction(CurvesSteps));
403     moduleObj->SetProperty(runtime, STEPS_CURVE, runtime->NewFunction(StepsCurve));
404     moduleObj->SetProperty(runtime, SPRING_MOTION, runtime->NewFunction(SpringMotionCurve));
405     moduleObj->SetProperty(runtime, RESPONSIVE_SPRING_MOTION, runtime->NewFunction(ResponsiveSpringMotionCurve));
406     moduleObj->SetProperty(runtime, CURVES_CUSTOM, runtime->NewFunction(CustomCurve));
407 
408 }
409 
410 } // namespace OHOS::Ace::Framework