MCPcopy Create free account
hub / github.com/32comic/image2pixel-web / getAvg

Method getAvg

web/js/algorithms.js:70–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68 this.splitChannel = rRange >= gRange && rRange >= bRange ? 0 : gRange >= bRange ? 1 : 2;
69 }
70 getAvg() {
71 const n = this.pixels.length;
72 let r = 0, g = 0, b = 0;
73 for (const p of this.pixels) { r += p[0]; g += p[1]; b += p[2]; }
74 return [Math.round(r / n), Math.round(g / n), Math.round(b / n)];
75 }
76 split() {
77 if (this.pixels.length < 2) return null;
78 const ch = this.splitChannel;

Callers 1

medianCutGetPaletteFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected