-
Scripting: Change group color dynamicly
Hi,
i am trying to create a Script that let me change a group color dynamicly.
At this moment i get this code and cant make it works.
If you see the code below there is a line with comments that i wish to use but doesnt work.
My intention is that when i modify a slider the group change of background color and when i click in button, it creates a solid with that color (the code of create solid isnt there).
Now the group only change color if i click on him but it only change with predefined colors…
What im doing wrong? This is possible?
Thanks a lot.
win=new Window("palette","SolidColor",[0,0,210,210],{resizeable:true,borderless:true,minimizeButton:false,maximizeButton:false,resizeable:false,});panel_color=win.add("panel",[5,5,210,220]);
group = win.add("panel",[5,5,205,40]);
group.graphics.backgroundColor= group.graphics.newBrush(group.graphics.BrushType.SOLID_COLOR, [.1, .5, .7], 1);
group.addEventListener ("click", function (m){handleMouseDown(m,group)});slider_h=panel_color.add("slider",[40,50,190,63],65,0,100);
slider_s=panel_color.add("slider",[40,90,190,103],47.8494623655914,0,100);
slider_l=panel_color.add("slider",[40,130,190,143],47.8494623655914,0,100);
runBtn=panel_color.add("button",[12,170,142,192],"Generar");exitBtn=panel_color.add("button",[160,170,180,192],"X");
hue_txt=win.add("statictext",[15,55,85,75] ,"Hue",{multiline:true});
sat_txt=win.add("statictext",[15,95,85,115] ,"Sat",{multiline:true});
lum_txt=win.add("statictext",[15,135,85,155] ,"Lum",{multiline:true});var h = parseFloat(slider_h.value / 100).toFixed(2);
var s = parseFloat(slider_s.value / 100).toFixed(2);
var l = parseFloat(slider_l.value / 100).toFixed(2);win.center();
runBtn.onClick = function ()
{
getColorValues ();
alert(h + " , " + s + " , " + l, "Hue, Saturation, Luminance");
}exitBtn.onClick = function ()
{
win.close();
}function getColorValues()
{
h = parseFloat(slider_h.value / 100).toFixed(2);
s = parseFloat(slider_s.value / 100).toFixed(2);
l = parseFloat(slider_l.value / 100).toFixed(2);}
function handleMouseDown(ev,theButton){
getColorValues();
theButton.graphics.backgroundColor = theButton.graphics.newBrush(theButton.graphics.BrushType.SOLID_COLOR, [.5, .2, .3], 1); // Works Fine
// theButton.graphics.backgroundColor = theButton.graphics.newBrush(theButton.graphics.BrushType.SOLID_COLOR, [h, s, l], 1); // Dont Work}
win.center();
win.show();