I'm working on a project that deals with pseudo random event-driven color changes and needed a solution to generate hexadecimal codes for web use.
I know that hexadecimal color codes represent red green and blue values in base 16. Which are defined by the following pattern:
I started thinking about what type and data structure to use in the implementation. I cam up with a general idea using a sets to define the base set and a general rule to build a six value hexadecimal color code.
- Where H is the set of hex values - These will be defined as strings.
The set 'Hexadecimal Color Code' - uses
At this point I was able to start writing some code. I will let the code speak for itself in the embed below.
As a Computer Science student and total nerd I have a question about this code.
Any other insights or comments would be appreciated.
After I implemented this I started thinking about doing more complex and potentially useful things with hex colors. For example, one could build on this idea and implement the code in such a way that only the
B get generated or a certain combination of the three.
Anyways, I hope some discussion arises from this, and this post was interesting.
If you enjoyed this content and want to support a poor freelancing student so I can eat and produce more content in the future, I accept donations via PayPal
Make better choices about your code and your career.