MCPcopy Index your code
hub / github.com/codrops/RainEffect / _parseBezierData

Function _parseBezierData

demo/js/index.js:6019–6058  ·  view source on GitHub ↗
(values, type, prepend)

Source from the content-addressed store, hash-verified

6017 return obj;
6018 },
6019 _parseBezierData = function(values, type, prepend) {
6020 type = type || "soft";
6021 var obj = {},
6022 inc = (type === "cubic") ? 3 : 2,
6023 soft = (type === "soft"),
6024 props = [],
6025 a, b, c, d, cur, i, j, l, p, cnt, tmp;
6026 if (soft && prepend) {
6027 values = [prepend].concat(values);
6028 }
6029 if (values == null || values.length < inc + 1) { throw "invalid Bezier data"; }
6030 for (p in values[0]) {
6031 props.push(p);
6032 }
6033 i = props.length;
6034 while (--i > -1) {
6035 p = props[i];
6036 obj[p] = cur = [];
6037 cnt = 0;
6038 l = values.length;
6039 for (j = 0; j < l; j++) {
6040 a = (prepend == null) ? values[j][p] : (typeof( (tmp = values[j][p]) ) === "string" && tmp.charAt(1) === "=") ? prepend[p] + Number(tmp.charAt(0) + tmp.substr(2)) : Number(tmp);
6041 if (soft) if (j > 1) if (j < l - 1) {
6042 cur[cnt++] = (a + cur[cnt-2]) / 2;
6043 }
6044 cur[cnt++] = a;
6045 }
6046 l = cnt - inc + 1;
6047 cnt = 0;
6048 for (j = 0; j < l; j += inc) {
6049 a = cur[j];
6050 b = cur[j+1];
6051 c = cur[j+2];
6052 d = (inc === 2) ? 0 : cur[j+3];
6053 cur[cnt++] = tmp = (inc === 3) ? new Segment(a, b, c, d) : new Segment(a, (2 * b + a) / 3, (2 * b + c) / 3, c);
6054 }
6055 cur.length = cnt;
6056 }
6057 return obj;
6058 },
6059 _addCubicLengths = function(a, steps, resolution) {
6060 var inc = 1 / resolution,
6061 j = a.length,

Callers 1

index.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected