Forums > MaxMSP

controlling a swatch with two dials – and vice-versa

March 17, 2012 | 11:38 am

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.

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

– Pasted Max Patch, click to expand. –
Attachments:
  1. RGBtoHSL.js

March 17, 2012 | 1:53 pm

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.

Attachments:
  1. RGBtoHSL.js

Viewing 2 posts - 1 through 2 (of 2 total)