Thanks Bob. I've been my own 5-10 minute hex--> decimal routine for development, but I don't want to put duplicate code into Jmol if I can avoid it. This looks like exactly what I need.
Jonathan On Mar 8, 2010, at 9:52 PM, Robert Hanson wrote: > Hiding?? now, now.... > > One question at a time... > > > On Sun, Mar 7, 2010 at 1:11 PM, Jonathan Gutow <gu...@uwosh.edu> > wrote: > Dear fellow developers: > > I know we somewhere have the code for translating rgb color codes > into hexadecimal (since scripts take either). > > org.jmol.util.Escape > > public static String getHexColorFromRGB(int argb) > > But this is really just translating base-10 ints into hex. > > Do we also have the reverse? And where are we hiding it? > > org.jmol.g3d.Graphics3D > > /** > * accepts [xRRGGBB] or [0xRRGGBB] or [0xFFRRGGBB] or #RRGGBB or > * [red,green,blue] or a valid JavaScript color > * > * @param strColor > * @return 0 if invalid or integer color > */ > public static int getArgbFromString(String strColor) > .... > > > > I'm trying to cleanly mesh some existing javascript widgets with > Jmol through WebExport and would prefer to translate hex colors to > rgb for initial settings as that is what the widgets speak. > > You could use: > > Point3f ptRGB = > Graphics3D.colorPointFromInt(Graphics3D.getArgbFromString(strColor)); > > Then ptRGB.x, ptRGB.y, and ptRGB.z are the red, green, and blue > components, respectively. > > > Bob > > > Jonathan > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Jmol-developers mailing list > Jmol-developers@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-developers > > > > -- > 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 > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Jmol-developers mailing list > Jmol-developers@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-developers Dr. Jonathan H. Gutow Chemistry Department gu...@uwosh.edu UW-Oshkosh Office:920-424-1326 800 Algoma Boulevard FAX:920-424-2042 Oshkosh, WI 54901 http://www.uwosh.edu/facstaff/gutow ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Jmol-developers mailing list Jmol-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-developers