MCPcopy Create free account
hub / github.com/breck7/scroll / blurf

Function blurf

external/.d3.js:180–199  ·  view source on GitHub ↗
(radius)

Source from the content-addressed store, hash-verified

178// integer, S[i - r - 1] and S[i + r + 1] are added to the sum, each weighted
179// according to r - ⌊radius⌋.
180function blurf(radius) {
181 const radius0 = Math.floor(radius);
182 if (radius0 === radius) return bluri(radius);
183 const t = radius - radius0;
184 const w = 2 * radius + 1;
185 return (T, S, start, stop, step) => { // stop must be aligned!
186 if (!((stop -= step) >= start)) return; // inclusive stop
187 let sum = radius0 * S[start];
188 const s0 = step * radius0;
189 const s1 = s0 + step;
190 for (let i = start, j = start + s0; i < j; i += step) {
191 sum += S[Math.min(stop, i)];
192 }
193 for (let i = start, j = stop; i <= j; i += step) {
194 sum += S[Math.min(stop, i + s0)];
195 T[i] = (sum + t * (S[Math.max(start, i - s1)] + S[Math.min(stop, i + s1)])) / w;
196 sum -= S[Math.max(start, i - s0)];
197 }
198 };
199}
200
201// Like blurf, but optimized for integer radius.
202function bluri(radius) {

Callers 2

blurFunction · 0.85
blurfImageFunction · 0.85

Calls 3

bluriFunction · 0.85
minMethod · 0.80
maxMethod · 0.80

Tested by

no test coverage detected