Page 1 of 1

lemur color

Posted: 04 Apr 2014 20:36
by analog604
Hi!

What is the formula to convert a lemur color value (color="65793") to the RGB values?

I'm not asking so I can do this in Lemur script, but for an JZML to Canvas object code conversion program that I have written.

Jay

Re: lemur color

Posted: 05 Apr 2014 14:42
by electrofux
Not sure but wasnt the colorpicker in the Lemur Modules Forum doing the conversion?

https://forum.liine.net/viewtopic.php?p=13248#p13248

Re: lemur color

Posted: 05 Apr 2014 18:52
by analog604
While the colorpicker in that template is neat (and I have seen that thread), I need to do the opposite. :o

Again not using Lemur scripting, but another language PERL.

Even without the colors being translated to the canvas RGB, the program does create working Lemur canvas_ script which can save days of scripting work in Lemur. :)

It turns all switches and pads (even multicolumn) into hit regions so on_cursor scripting is much less.. painful. Also draws the regions.

One could do page layout in the editor, run the canvas convertor, then copy the output to another template as code... without being an expert in canvas_ scripting. Still it is basic, no fancy arcs and curves yet.

Jay

Re: lemur color

Posted: 06 Apr 2014 01:34
by Macciza
Hi
You need to reverse the colour formula mentioned in the manual
I recall doing it at some time, not sure if it is posted here or somewhere on my drive
Will try to find it or redo it,

Cheers

Re: lemur color

Posted: 06 Apr 2014 03:17
by Macciza
Yeah
Here you go - try this as a one-liner . . .
asRGB(colour) = {( color >> 16 ) & 0xFF,( color >> 8 ) & 0xFF,color & 0xFF}/127 // returns 0...1 values

As 7 bit 0 - 127 values
asRGB_7(colour) = {( color >> 16 ) & 0xFF,( color >> 8 ) & 0xFF,color & 0xFF}

And to reverse . . .
asColor_7(r,g,b) = (r << 16) + (g << 8) + b

Cheers
MM

Edit: first version was for returning 7 bit values, fixed now for asRGB(colour) to return 0....1 values

Re: lemur color

Posted: 06 Apr 2014 21:56
by analog604
Hi Macciza! That is fantastic, thank you for the code. I integrated the formula into the converter program without issue. :)

Re: lemur color

Posted: 07 Apr 2014 02:44
by Macciza
No worries
Are you looking at posting the code at all?

Cheers
MM

Re: lemur color

Posted: 07 Apr 2014 10:35
by analog604
Yes I'll be posting the code and perhaps a little intro on how to use it.

Re: lemur color

Posted: 17 Apr 2014 19:31
by Joe Soap
This sounds legendary.

Re: lemur color

Posted: 18 Apr 2014 13:46
by analog604
and.. I am pleased to report that it works and will produce a working JZLIB (or only raw script code). :D
Still have some fine tuning to go before posting it, but the savings in time for creating cursor hit regions out of a multi-row switch or pad is amazing. It can optionally turn objects into an array of circles and rounded rectangles, also with hit regions.
If one of you guys are comfortable running Perl on the command line, let me know (PM me) and you can try it out.
I test it in OS X terminal, but it will run within any other unix shell or possibly Windows with Perl installed.