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

Method getAverageColor

web/js/main.js:480–483  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

478 this.splitChannel = ranges.indexOf(this.largestRange);
479 }
480 getAverageColor() {
481 const sum = this.pixels.reduce((a, b) => a.map((v, i) => v + b[i]), [0,0,0,0]);
482 return sum.map(v => Math.round(v / this.pixels.length));
483 }
484 split() {
485 if (this.pixels.length < 2) return null;
486 this.pixels.sort((a, b) => a[this.splitChannel] - b[this.splitChannel]);

Callers 1

medianCutQuantizationFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected