let setColor = (rgba,url) =>{
   return new Promise(resolve =>{
	var img = new Image();
	img.src = url;
	img.onload = () => {
		const width = img.width;
		const height = img.height;
		const canvas = docuemnt.createElement("canvas");
		canvas.width = width
		canvas.height = height
		var ctx = canvas.getContext("2d");
		ctx.drawImage(img,0,0)
		var data = ctx.getImageData(0,0,width,height)
		var num = 0;
		for (let i = 0; i < data.data.length; i+=4) {
			var r = data.data[i];
			var g = data.data[i+1];
			var b = data.data[i+2];
			var a = data.data[i+3];
			if(r + min < rgba[0] 
				&& r + max > rgba[0]
				&& g + min < rgba[1] 
				&& g + max > rgba[1]
				&& b + min < rgba[2]
				&& b + max > rgba[2]
				&& a == rgba[3]){
					num++
				}
		}
		resolve({
			width,height,num
		})
		img.remove()
	}
   })
};

export default setColor