PHP Classes

File: vendors/gentelella/vendors/jqvmap/src/ColorScale/getColor.js

Recommend this page to a friend!
  Classes of Jorge Castro   Gentelella BladeOne   vendors/gentelella/vendors/jqvmap/src/ColorScale/getColor.js   Download  
File: vendors/gentelella/vendors/jqvmap/src/ColorScale/getColor.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Gentelella BladeOne
Render templates using Bootstrap for presentation
Author: By
Last change:
Date: 3 years ago
Size: 999 bytes
 

Contents

Class file image Download
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; };