Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: color picker
name
code content
( var res = 20, scrsize = 200, val, set, win, scr, currentColor = Color.gray, setColor; win = Window.new("color picker",Rect(400, 400, 2*scrsize+20, scrsize),false).front; //win.view.background_(Color.white); scr = UserView.new(win,Rect(scrsize+20, 0, scrsize, scrsize)); scr.background_(Color.white); setColor = {|x, y, val, postVal=false| //x = x/scrsize; //y = y/scrsize; currentColor = Color.hsv(min(0.999, x), min(0.999, 1-y), val, 1); postVal.if{ // ("Color.hsv("++(x)++", "++(1-y)++", "++val.value++", 1)").postln; "Color.new255(%, %, %)".format(*(currentColor.asArray*255)).postln; }; scr.background_( Color.hsv(min(0.999, x), min(0.999, 1-y), val.value, 1) ); }; val = Slider(win, Rect(scrsize, 0, 20, scrsize)).value_(1).action_({|view| setColor.(m.x.postln, m.y, view.value); win.refresh }); m = Slider2D(win, Rect(0, 0, scrsize, scrsize)) .mouseDownAction_({|view| setColor.(view.x, view.y, val.value); win.refresh }) .mouseMoveAction_({|view| setColor.(view.x, view.y, val.value); win.refresh }).mouseUpAction_({|view| setColor.(view.x, view.y, val.value, true); win.refresh }); win.front; )
code description
A simple color picker. Posts picked color to the postwindow. Based on (non-functional) code found at http://swiki.hfbk-hamburg.de:8888/MusicTechnology/868 (scsolar 2007)
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change