View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

ColorPicker

Home   How To   Code Pool   Public Library   Theory   Events
using a HSV display

 

(

var res = 20, scrsize = 200, val, set, win, scr;
win = SCWindow.new("SCColorChooser",Rect(400, 400, 2*scrsize+20, scrsize),false).front;
win.view.background_(Color.white);
scr = SCCompositeView.new(win,Rect(scrsize+20, 0, scrsize, scrsize));
scr.background_(Color.white);
val = SCSlider(win, Rect(scrsize, 0, 20, scrsize)).value_(1).action_({win.refresh});
m = SC2DTabletSlider(win, Rect(0, 0, scrsize, scrsize))
	.mouseDownAction_({arg view, x, y; 
		("Color.hsv("++(x)++", "++(1-y)++", "++val.value++", 1)").postln; 
		Color.hsv(min(0.999, x), min(0.999, 1-y), val.value, 1).postln; 
		scr.background_(Color.hsv(min(0.999, x), min(0.999, 1-y), val.value, 1));
	});
win.drawHook = {
	res.do({ arg i;
		res.do({ arg j;
			Color.hsv(1/res*i,1/res*j, val.value, 1).set;
			Pen.fillRect(Rect((scrsize/res)*i, (scrsize/res)*j, (scrsize/res), (scrsize/res)));
		})
	})
};
win.front;

)

// SCColorChooser by scsolar 10.2007


Link to this Page