MCPcopy
hub / github.com/ampproject/amphtml / getCurve

Function getCurve

src/core/data-structures/curve.js:265–290  ·  view source on GitHub ↗
(curve)

Source from the content-addressed store, hash-verified

263 * @return {?CurveDef}
264 */
265export function getCurve(curve) {
266 if (!curve) {
267 return null;
268 }
269 if (isString(curve)) {
270 curve = /** @type {string} */ (curve);
271 // If the curve is a custom cubic-bezier curve
272 if (curve.indexOf('cubic-bezier') != -1) {
273 const match = curve.match(/cubic-bezier\((.+)\)/);
274 if (match) {
275 const values = match[1].split(',').map(parseFloat);
276 if (values.length == 4) {
277 for (let i = 0; i < 4; i++) {
278 if (isNaN(values[i])) {
279 return null;
280 }
281 }
282 return bezierCurve(values[0], values[1], values[2], values[3]);
283 }
284 }
285 return null;
286 }
287 return NAME_MAP[curve];
288 }
289 return /** @type {CurveDef} */ (curve);
290}

Callers 3

test-curve.jsFile · 0.90
setCurveMethod · 0.90
addMethod · 0.90

Calls 2

isStringFunction · 0.90
bezierCurveFunction · 0.85

Tested by

no test coverage detected