var window, colors, i_width = 100, pad = 10;

colors = Color.black!3;

window = SCWindow.new("Virtual Ambient Lights", Rect(400, 400, colors.size*(i_width+pad) + (2*pad), i_width+50)).front;
window.view.background_(Color.black);
window.drawHook = {
	var j;
	Pen.use {
		Pen.translate(10, 10);
		colors.do{|color, i| 
			color.set;
			// Pen.fillRect(Rect(pad/2, 0, i_width, i_width));
			//Pen.addAnnularWedge(Point(*((pad+i_width)/2)!2), 0, i_width*0.35, 0, 2pi);
			/*Pen.addArc(Point(*((pad+i_width)/2)!2), i_width*0.5, 0.5pi, 2pi);
			Pen.stroke;*/
			20.do{|i|
				j = (i+1)*0.05;
				Color.black.blend(color, j*0.5).set;
				Pen.addArc(
					Point(*(((pad+i_width)*0.5)!2)), 
					i_width*0.7   * (1-j),
					pi,
					2pi
				);
				Pen.fill;
			};
			Pen.translate(i_width+pad, 0);
		}
	}

};

OSCresponder(NetAddr.localAddr, "/orb", {|time, resp, msg|
	var which, color, oldColor, lagTime, numSteps, fps = 20, rFps;
	which = msg[1];
	color = Color.new255(*msg[2..4]);
	oldColor = colors[which];
	lagTime = msg[5];
	numSteps = lagTime*fps;
	rFps = fps.reciprocal;
	
	Task({
		numSteps.do{|i|
			colors[which] = oldColor.valueBlend(color, i/numSteps);
			window.refresh;
			rFps.wait
		};
		colors[which] = color;
		window.refresh;
	}, AppClock).start;
}).add