Sha256: 42e74b3a89509ad51dd6c9d8ca87bcb10683951a293b577781d22c3af1f93fc3
Contents?: true
Size: 999 Bytes
Versions: 2
Compression:
Stored size: 999 Bytes
Contents
ColorScale.prototype.getColor = function (value) { if (typeof this.normalize === 'function') { value = this.normalize(value); } var lengthes = []; var fullLength = 0; var l; for (var i = 0; i < this.colors.length - 1; i++) { l = this.vectorLength(this.vectorSubtract(this.colors[i + 1], this.colors[i])); lengthes.push(l); fullLength += l; } var c = (this.maxValue - this.minValue) / fullLength; for (i = 0; i < lengthes.length; i++) { lengthes[i] *= c; } i = 0; value -= this.minValue; while (value - lengthes[i] >= 0) { value -= lengthes[i]; i++; } var color; if (i === this.colors.length - 1) { color = this.vectorToNum(this.colors[i]).toString(16); } else { color = (this.vectorToNum(this.vectorAdd(this.colors[i], this.vectorMult(this.vectorSubtract(this.colors[i + 1], this.colors[i]), (value) / (lengthes[i]))))).toString(16); } while (color.length < 6) { color = '0' + color; } return '#' + color; };
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails_modular_admin-1.0.0 | app/assets/node_modules/jqvmap/src/ColorScale/getColor.js |
rails_modular_admin-0.4.0 | app/assets/node_modules/jqvmap/src/ColorScale/getColor.js |