[javascript-dev] horizontal slider
Emmanuel Jourdan
c74-mailinglists at e--j.com
Sun Sep 16 14:48:35 MDT 2007
- Previous message: [javascript-dev] horizontal slider
- Next message: [javascript-dev] Re: horizontal slider
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 16 sept. 07, at 20:52, Garrett Lynch wrote:
> hi
>
> Trying to modify the vertical jsui slider in max as a horizontal
> slider. I think i am nearly there but I can't figure out the final
> math to get the mouse sensitivity to be correct. can anyone see
> where I am going wrong? Thanks in advance.
The x axis is between -aspect and +aspect which depends on the width/
height ratio. So you just have to calculate the aspect and scale your
f value to be between 0 and 1:
function ondrag(x,y,but,cmd,shift,capslock,option,ctrl)
{
var f,a, height, width, aspect;
height = box.rect[3] - box.rect[1];
width = box.rect[2] - box.rect[0];
aspect = width/height;
a = sketch.screentoworld(x,y);
//detect horizontal movement
f = (a[0] + aspect) / (2*aspect);
msg_float(f); //set new value with clipping + refresh
}
HTH,
ej
- Previous message: [javascript-dev] horizontal slider
- Next message: [javascript-dev] Re: horizontal slider
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
