|
|
@ -20,14 +20,22 @@ showFullContent: false
|
|
|
|
- Generate an RGB or RGBA color code for it in a deterministic way
|
|
|
|
- Generate an RGB or RGBA color code for it in a deterministic way
|
|
|
|
- SHA1 the string
|
|
|
|
- SHA1 the string
|
|
|
|
- Interpret equally sized chunks of the hash as integers
|
|
|
|
- Interpret equally sized chunks of the hash as integers
|
|
|
|
- Scale those integers into an 8-bit space
|
|
|
|
- Scale those integers into an 8-bit unsigned space
|
|
|
|
## The Implementation
|
|
|
|
## The Implementation
|
|
|
|
|
|
|
|
### Hashing
|
|
|
|
|
|
|
|
{{< highlight go > }}
|
|
|
|
|
|
|
|
{{</ highlight > }}
|
|
|
|
|
|
|
|
### Interpolation
|
|
|
|
|
|
|
|
- Not sure if interpolation is the right technical term
|
|
|
|
|
|
|
|
- Using generics
|
|
|
|
|
|
|
|
{{< highlight go > }}
|
|
|
|
|
|
|
|
{{</ highlight > }}
|
|
|
|
## The Results
|
|
|
|
## The Results
|
|
|
|
Below is a sample of the "lorum ipsum" text with each word colored using this algorithm.
|
|
|
|
Below is a sample of "lorem ipsum" with each word colored using this algorithm.
|
|
|
|
|
|
|
|
|
|
|
|
<p><span style="color:#FDC749;">Lorem</span> <span style="color:#D39A85;">ipsum</span> <span style="color:#452D59;">dolor</span> <span style="color:#3A852F;">sit</span> <span style="color:#0454D4;">amet</span>, <span style="color:#886B09;">consectetur</span> <span style="color:#31A0E5;">adipiscing</span> <span style="color:#99215D;">elit</span>. </p>
|
|
|
|
<p><span style="color:#FDC749;">Lorem</span> <span style="color:#D39A85;">ipsum</span> <span style="color:#452D59;">dolor</span> <span style="color:#3A852F;">sit</span> <span style="color:#0454D4;">amet</span>, <span style="color:#886B09;">consectetur</span> <span style="color:#31A0E5;">adipiscing</span> <span style="color:#99215D;">elit</span>. </p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
It doesn't look too bad.
|
|
|
|
|
|
|
|
|
|
|
|
## Possible Improvements
|
|
|
|
## Possible Improvements
|
|
|
|
- Provide HSV or HSL color values
|
|
|
|
- Provide HSV or HSL color values
|