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

Function _parseLengthData

demo/js/index.js:6079–6107  ·  view source on GitHub ↗
(obj, resolution)

Source from the content-addressed store, hash-verified

6077 }
6078 },
6079 _parseLengthData = function(obj, resolution) {
6080 resolution = resolution >> 0 || 6;
6081 var a = [],
6082 lengths = [],
6083 d = 0,
6084 total = 0,
6085 threshold = resolution - 1,
6086 segments = [],
6087 curLS = [], //current length segments array
6088 p, i, l, index;
6089 for (p in obj) {
6090 _addCubicLengths(obj[p], a, resolution);
6091 }
6092 l = a.length;
6093 for (i = 0; i < l; i++) {
6094 d += Math.sqrt(a[i]);
6095 index = i % resolution;
6096 curLS[index] = d;
6097 if (index === threshold) {
6098 total += d;
6099 index = (i / resolution) >> 0;
6100 segments[index] = curLS;
6101 lengths[index] = total;
6102 d = 0;
6103 curLS = [];
6104 }
6105 }
6106 return {length:total, lengths:lengths, segments:segments};
6107 },
6108
6109
6110

Callers 1

index.jsFile · 0.85

Calls 1

_addCubicLengthsFunction · 0.85

Tested by

no test coverage detected