+ 7

Why doesn't this code work?

I made code published with name "SMOOTH RANFOM COLOR CHANGING".

30th Jan 2017, 7:39 AM
Aydin
1 Respuesta
+ 3
You don't have a public code with the name of "SMOOTH RANFOM COLOR CHANGING", but the one mostly approaching is "Random colors!!!" To make it smooth changing, simply add this rule to yours css definitions: body, h1 { transition:all 0.9s; } Another basic improvment you can do, is to not generate two randoms colors for background/foreground, and instead set one with the complementary of the other : - #FFFFFF give #000000 and reciprocally ( white and black respectivly ) - #FF0000 give #00FFFF which are red and yellow... and so on. By this way, you reduce the probability that the two colors wouldn't have enough contrast ( the only except is for middle gray values around #808080, but you can also avoid a range of gray values, by filtering and re-random number if it's triple same value for each rgb components: range 40 to C0 should be sufficient if you don't want avoid all grays including black and white ) To handle that, you can keep your way to generate random colors, by generating the second color with a reversed version of your array of hexadecimal digit, as well as refactoring it for the occasion, by generating random numbers in range of 256 instead of 16 ( or, once you can do for encoding two digits in hexadecimal, you can do for six :P ), and get the complementary mathematically ;)
31st Jan 2017, 10:02 AM
visph
visph - avatar