[FINITO] Can this be speeded up? Plz help (Nice Hex Color Pa

JavaScript and client side scripting.

Moderator: General Moderators

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

psst, Code Snippets ;) :lol:
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

BTW... if you want the highlighted version that's easier to read click here... http://www.chriscorbyn.co.uk/colors/source.php - It'll be nice when we get our PHP tags back. I really should get to bed now or I'm gonna be driving to work late at 100mph :wink:
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I changed

Code: Select all

r_hex -= inc_x_r //followed by (at the top of the loop)
if (r_hex < 0) &#123;
    r_hex = 0
&#125;
To just say

Code: Select all

r_hex = Math.max(0, (r_hex - inc_x_r))
Not sure if it's actually faster or not.... I think I'm just shaving milliseconds of now so it's hard to tell. Logically it would be faster because you overwrite the variable less often right? and it's not going through condition checks
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Ok I think I've done enough on this now... It's never gonna be instant with so much to process but it only take millisecs now which is BIG improvement on the start of this post for anybody who happened to check it.

I'm not adding anything fancier... it works well so let's leave it at that.

Code posted in snippet here.... viewtopic.php?p=156829#156829 as promised so you can do as you please with it but please update the post if you do make any changes because I'll be interested to see them.

Actual PHP source http://www.chriscorbyn.co.uk/colors/source.php

Thanks for all your help on this!!!
Post Reply