Demo - Color

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.grapecity.com/wijmo/5.latest/styles/wijmo.min.css">
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.input.min.js"></script>
<div class="container">

  <h1>
    Color
  </h1>
  <p>
    The <b>Color</b> class parses colors specified as CSS strings
    and exposes their red, green, blue, and alpha channels as read-write 
    properties.</p>
  <p>
    It also provides <b>fromHsb</b> and <b>fromHsl</b> methods for creating
    colors using the HSB and HSL color models instead of RGB, as well as
    <b>getHsb</b> and <b>getHsl</b> methods for retrieving the color 
    components using those color models.</p>
  <p>
    The <b>Color</b> class also has an <b>interpolate</b> method that creates
    colors by interpolating between two colors using the HSL model. This 
    method is especially useful for creating color animations with the 
    <b>animate</b> method.</p>
  <p>
    The example below illustrates:
  </p>    
  <div>
    <div id="clrStart"></div>
    <div id="clrEnd"></div>
  </div>    
  <table>
    <tr id="theColorRow"></tr>
  </table>
  <div id="theColor">
  <div>
  
  </div>
  </div>
</div>

CSS

.wj-control {
  margin-bottom: 12px;
}
table {
  width: 100%;
}
#theColor {
  width: 150px;
  height: 150px;
  margin: 12px auto;
  border: 2px solid black;
  background-color: grey;
}

JavaScript

onload = function() {

	// create color pickers
	var clrStart = new wijmo.input.InputColor('#clrStart', {
  	value: 'purple',
    valueChanged: interpolate
  });
	var clrEnd = new wijmo.input.InputColor('#clrEnd', {
  	value: 'red',
    valueChanged: interpolate
  });
  interpolate();
  
  // interpolate colors
  var animInt;
  function interpolate() {

		// remove old gradient
    var tr = document.getElementById('theColorRow');
		while (tr.hasChildNodes()) {
    	tr.removeChild(tr.lastChild);
		}    

		// calculate new gradient
		var c1 = new wijmo.Color(clrStart.value),
    		c2 = new wijmo.Color(clrEnd.value),
        cnt = 80;
    for (var i = 0; i < cnt; i++) {
			var td = document.createElement('td');
      td.innerHTML = '&nbsp;'
      td.style.background = wijmo.Color.interpolate(c1, c2, i / cnt);
      tr.appendChild(td);
    }
    
    // animate the color
    var theColor = document.getElementById('theColor');
    clearInterval(animInt);
    animInt = wijmo.animate(function(pct) {
    	theColor.style.background = wijmo.Color.interpolate(c1, c2, pct);
    }, 2000);
    
  }
}