controlling a swatch with two dials - and vice-versa

discopatrick's icon

Here's my patch, where I use two dials to control the Hue and Luminance values of a HSL colour definition, and feed that to a swatch object.

The swatch object is settable by clicking on it, and if the user does so, I want the dials to reflect this. So I've added this functionality in a kind of loopback (being careful not to actually create an infinite loop).

The patch works almost perfectly, except for one small thing - if you move the right hand dial, and then the left dial, the right dial jumps to the initial value of the left dial.

All my debugging efforts have not been able to figure out why this is happening, and so I'm hoping someone here can help.

Max Patch
Copy patch and select New From Clipboard in Max.

The patch includes a js object, the source file for which I have attached to this post.

3558.RGBtoHSL.js
js
discopatrick's icon

Have just spotted a typo in my js code.

Line 50 was:if ( h > 1 ) { h -+ 1 }

It should of course be:if ( h > 1 ) { h -= 1 }

However, this hasn't solved the problem. I'll re-upload the corrected js file anyway.

3559.RGBtoHSL.js
js