Some suggestions:

JmolColorPickerBox("colorBox1", "rgb(100,100,100)", "0", scriptStr2);

Jmol.js style is to allow for defaults wherever possible, so I suggest:

  JmolColorPickerBox(jmolScript, initialColor, boxID, appletID)

where all except jmolScript could be default, and "initialColor" could be a
simple array: [100,100,100].

Here's my suggestion for a simpler method of setting the colors:

    var rgbs=[[255,0,0]
        ,[255,128,0]
        ,[255,255,0]
        ,[128,255,0]
        ,[0,255,0]
        ,[0,255,128]
        ,[0,255,255]
        ,[0,128,255]
        ,[0,0,255]
        ,[128,0,255]
        ,[255,0,255]
        ,[255,255,255]
    ]
    var hues=[100,90,80,70,60,50,40]

    htmlStr = '<table cellspacing="0" cellpadding="0" border="0"><tbody>';
    for (j = 0; j <= hues.length;j++){
    htmlStr += '<tr>'
    var f = hues[j]/100.0;
        for (k = 0; k < rgbs.length; k++){
        r = Math.round(rgbs[k][0] * f)
        g = Math.round(rgbs[k][1] * f)
        b = Math.round(rgbs[k][2] * f)
           htmlStr +='<td style="background-color: rgb(' + r + "," + g + ","
+ b + ');">';
           htmlStr +='<div style="width: 6px; height: 6px;"
onclick=\'pickedColor("rgb('+r+','+g+','+b+')");\'></div>';
           htmlStr +='</td>';
        }//for k
    htmlStr +='</tr>';
    }//for j
    htmlStr += '</tbody></table>';


That seems to me to be more understandable.

Perhaps a file "JmolWidgets.js" would be in order -- and could have this and
other interesting JavaScript elements, such as sliders and "tape player"
functions for animation.

This could be the start of a great addition to Jmol, Jonathan!

Bob



On Sat, Jan 2, 2010 at 8:45 PM, Robert Hanson <[email protected]> wrote:

> Nice! Let's see if we can tighten that code up a bit....
>
>
> On Sat, Jan 2, 2010 at 3:35 PM, Jonathan Gutow <[email protected]> wrote:
>
>> Dear Jmol Users:
>>
>>        (What I did on my holiday break...:)) As part of my work on the
>> Jmol
>> interface for the SAGEmath project, I have put together a color picker
>> box that pops up a palette of colors to choose from and then passes
>> the user's choice into a Jmol script which is then passed to the
>> applet.  I don't think it would take much more effort to make this
>> work as part of Jmol.js.  However, before I and possibly other people
>> put any effort towards that, I wanted to find out if the Jmol
>> community thinks this is something they would use.
>>
>> Please take a look at the example page showing the color picker box in
>> action to see what I'm talking about:
>>
>>
>> http://www.uwosh.edu/faculty_staff/gutow/Jmol_Web_Page_Maker/JmolColorPicker/Jmol%20Color%20Picker%20Test.html
>>
>> Then please vote directly to this list with a
>>
>> yes or +1 (for you would like to see it included)
>>
>> or
>>
>> no  or -1 (for you can't see a use for this)
>>
>> Also comments about how it looks or functions would be useful.
>>
>> Then I and other people working on Jmol development can decide how
>> much more effort to put towards this.
>>
>> Thanks,
>> Jonathan
>>                          Dr. Jonathan H. Gutow
>> Chemistry Department                                 [email protected]
>> UW-Oshkosh                                           Office:920-424-1326
>> 800 Algoma Boulevard                                 FAX:920-424-2042
>> Oshkosh, WI 54901
>>                  http://www.uwosh.edu/facstaff/gutow
>>
>>
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Verizon Developer Community
>> Take advantage of Verizon's best-in-class app development support
>> A streamlined, 14 day to market process makes app distribution fast and
>> easy
>> Join now and get one step closer to millions of Verizon customers
>> http://p.sf.net/sfu/verizon-dev2dev
>> _______________________________________________
>> Jmol-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>>
>
>
>
> --
> Robert M. Hanson
> Professor of Chemistry
> St. Olaf College
> 1520 St. Olaf Ave.
> Northfield, MN 55057
> http://www.stolaf.edu/people/hansonr
> phone: 507-786-3107
>
>
> If nature does not answer first what we want,
> it is better to take what answer we get.
>
> -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
>



-- 
Robert M. Hanson
Professor of Chemistry
St. Olaf College
1520 St. Olaf Ave.
Northfield, MN 55057
http://www.stolaf.edu/people/hansonr
phone: 507-786-3107


If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to