MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / parseCubicBezierCurve

Function parseCubicBezierCurve

packages/core/ui/styling/converters.ts:25–36  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

23}
24
25function parseCubicBezierCurve(value: string) {
26 const coordsString = /\((.*?)\)/.exec(value);
27 const coords = coordsString && coordsString[1].split(',').map(stringToBezieCoords);
28
29 if (value.startsWith('cubic-bezier') && coordsString && coords.length === 4) {
30 const [x1, x2, y1, y2] = [...coords];
31
32 return CoreTypes.AnimationCurve.cubicBezier(x1, x2, y1, y2);
33 } else {
34 throw new Error(`Invalid value for animation: ${value}`);
35 }
36}
37
38function stringToBezieCoords(value: string): number {
39 const result = parseFloat(value);

Callers 1

Calls 1

mapMethod · 0.65

Tested by

no test coverage detected