Thanks for the great post Fabian it was really helpful.
I had a quick question :
at line 12 where you are defining an array of random colors, why is 1 shifted 24 times?
more specifically I would like to know how does that bitwise logic really work?
I tried 16 and 32 and got different color schemes but I couldn't figure out why.
I know it probably sounds like a stupid question but I am totally new to bitwise operations :)
A08M31, the only stupid question is the one that you don't ask.
When you play with values 8, 16, 24 ..., it generates a set of colors; with 16 bits, obviously the number of colors generated is small (65,535 colors) unlike the 24 bits which can represent 16,777,216 different colors (by the way the human eye can only distinguish 10 million colors), if you change it to 32 bits it probably can not be represented on certain computers. Thanks to your comment I decided to analyze this line of code in depth, and I realized that sometimes it does not generate a valid color, because the code used here is copy/paste ( :D ), from stackoverflow, the solution to this problem is in the following link, codegolf.stackexchange.com/questio...
Do not forget to read the next part of this blog, because you will find more interesting things!
Thank You!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the great post Fabian it was really helpful.
I had a quick question :
at line 12 where you are defining an array of random colors, why is 1 shifted 24 times?
more specifically I would like to know how does that bitwise logic really work?
I tried 16 and 32 and got different color schemes but I couldn't figure out why.
I know it probably sounds like a stupid question but I am totally new to bitwise operations :)
A08M31, the only stupid question is the one that you don't ask.
When you play with values 8, 16, 24 ..., it generates a set of colors; with 16 bits, obviously the number of colors generated is small (65,535 colors) unlike the 24 bits which can represent 16,777,216 different colors (by the way the human eye can only distinguish 10 million colors), if you change it to 32 bits it probably can not be represented on certain computers. Thanks to your comment I decided to analyze this line of code in depth, and I realized that sometimes it does not generate a valid color, because the code used here is copy/paste ( :D ), from stackoverflow, the solution to this problem is in the following link, codegolf.stackexchange.com/questio...
Do not forget to read the next part of this blog, because you will find more interesting things!
Thank You!