res/draw.js
function getColors (image, cb) {
	var data = [];

	var img = createImage(image);

	var promise = new Promise(function (resolve) {
		img.onload = function () {
			var canvas = document.createElement('canvas');
			canvas.width = img.width;
			canvas.height = img.height;
			canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height);

			var ctx = canvas.getContext('2d');

			var imageData = ctx.getImageData(0, 0, img.width, 1).data;

			for (var i = 0; i < img.width; i++) {
				data.push([imageData[i*4]/255, imageData[i*4+1]/255, imageData[i*4+2]/255]);
			}

			resolve(data);
		};
	});


	return promise;
}
function getColors (image, cb) {
	var data = [];

	var img = createImage(image);

	var promise = new Promise(function (resolve) {
		img.onload = function () {
			var canvas = document.createElement('canvas');
			canvas.width = img.width;
			canvas.height = img.height;
			canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height);

			var ctx = canvas.getContext('2d');

			var imageData = ctx.getImageData(0, 0, img.width, 1).data;

			for (var i = 0; i < img.width; i++) {
				data.push([imageData[i*4]/255, imageData[i*4+1]/255, imageData[i*4+2]/255]);
			}

			resolve(data);
		};
	});


	return promise;
}
function getColors ( image , cb ) { var data = [ ] ; var img = createImage ( image ) ; var promise = new Promise ( function ( resolve ) { img . onload = function ( ) { var canvas = document . createElement ( 'canvas' ) ; canvas . width = img . width ; canvas . height = img . height ; canvas . getContext ( '2d' ) . drawImage ( img , 0 , 0 , img . width , img . height ) ; var ctx = canvas . getContext ( '2d' ) ; var imageData = ctx . getImageData ( 0 , 0 , img . width , 1 ) . data ; for ( var i = 0 ; i < img . width ; i ++ ) { data . push ( [ imageData [ i * 4 ] / 255 , imageData [ i * 4 + 1 ] / 255 , imageData [ i * 4 + 2 ] / 255 ] ) ; } resolve ( data ) ; } ; } ) ; return promise ; }
Helpers here get image colors
Helpers here get image colors