«Color Picker» by codepool

on 27 Apr'17 22:13 in guicolor picker

Migration from the old SourceForge wiki.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Color Picker GUIs

( // OSX Only

var res = 20, scrsize = 200, val, set, win, scr;
win = Window.new("SCColorChooser",Rect(400, 400, 2*scrsize+20, scrsize),false).front;
win.view.background_(Color.white);
scr = CompositeView.new(win,Rect(scrsize+20, 0, scrsize, scrsize));
scr.background_(Color.white);
val = Slider(win, Rect(scrsize, 0, 20, scrsize)).value_(1).action_({win.refresh});
m = TabletSlider2D(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



ColorPicker { // Class by Miguel Negrão

	*new {
		var w,r,g,b,update,color;
		w = Window.new("Color Picker",Rect(100,100,230,68),false);
		r = EZSlider(w, Rect(2,0,150,20),"R",labelWidth:20)
		.action_({ |v| update.(); });
		g = EZSlider(w, Rect(2,22,150,20),"G",labelWidth:20)
		.action_({ |v| update.(); });

		b = EZSlider(w, Rect(2,44,150,20),"B",labelWidth:20)
		.action_({ |v| update.(); });
		
		[r,g,b].do({|item| item.sliderView.canFocus_(false) });

		color = UserView(w,Rect(160,0,64,64))
		.background_(Color.black)
		.enabled_(true)
		.mouseDownAction_({ color.background.postln;})
		.beginDragAction_({color.background})
		.canFocus_(false);

		
		update = { color.background_(Color(r.value,g.value,b.value)) }; 

		w.front;

	}
}
raw 1756 chars (focus & ctrl+a+c to copy)
reception
comments
rafa_teck user 20 Sep'21 00:29

Hello!

Where can I find the TabletSlider2D class? Is it a Quark or is a personal class?

thank you