Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com please write me a code

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
10-24-2006, 08:27 PM   PM User | #1
tomas.srna
New to the CF scene

Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

Hi.

I have a tutorial how to convert rgb to hsl. Could anyone write it in Javascript for me?

Quote:
 RGB - HSL 1. Convert the RBG values to the range 0-1 Example: from the video colors page, colorbar red has R=83%, B=7%, G=7%, or in this scale, R=.83, B=.07, G=.07 2. Find min and max values of R, B, G In the example, maxcolor = .83, mincolor=.07 3. L = (maxcolor + mincolor)/2 For the example, L = (.83+.07)/2 = .45 4. If the max and min colors are the same (ie the color is some kind of grey), S is defined to be 0, and H is undefined but in programs usually written as 0 5. Otherwise, test L. If L < 0.5, S=(maxcolor-mincolor)/(maxcolor+mincolor) If L >=0.5, S=(maxcolor-mincolor)/(2.0-maxcolor-mincolor) For the example, L=0.45 so S=(.83-.07)/(.83+.07) = .84 6. If R=maxcolor, H = (G-B)/(maxcolor-mincolor) If G=maxcolor, H = 2.0 + (B-R)/(maxcolor-mincolor) If B=maxcolor, H = 4.0 + (R-G)/(maxcolor-mincolor) For the example, R=maxcolor so H = (.07-.07)/(.83-.07) = 0 7. To use the scaling shown in the video color page, convert L and S back to percentages, and H into an angle in degrees (ie scale it from 0-360). From the computation in step 6, H will range from 0-6. RGB space is a cube, and HSL space is a double hexacone, where L is the principal diagonal of the RGB cube. Thus corners of the RGB cube; red, yellow, green, cyan, blue, and magenta, become the vertices of the HSL hexagon. Then the value 0-6 for H tells you which section of the hexgon you are in. H is most commonly given as in degrees, so to convert H = H*60.0 If H is negative, add 360 to complete the conversion.
Thanks

 10-24-2006, 08:52 PM PM User | #2 Philip M Supreme Master coder!     Join Date: Jun 2002 Location: London, England Posts: 17,467 Thanks: 200 Thanked 2,468 Times in 2,446 Posts Sorry, we are not here to do your homework for you. See the rules:- 1.5) No homework assignments - Do not post your entire homework assignment and request that other members do it for you. This is considered cheating, and your thread may even be used by your school to prove your guilt. Now, you may ask for advice or help on a specific aspect of your assignment that you're having trouble with. Use common sense as far as what's acceptable in terms of soliciting help with homework assignments.
 10-24-2006, 10:03 PM PM User | #3 mrhoo Regular Coder   Join Date: Mar 2006 Posts: 719 Thanks: 34 Thanked 130 Times in 121 Posts You need to change your major from programming to management...
 10-27-2006, 10:35 PM PM User | #4 kencl New Coder   Join Date: May 2003 Posts: 15 Thanks: 0 Thanked 0 Times in 0 Posts Sure: Write Code

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 11:48 PM.