#12 - Automatic tag color
Date: 2018-06-09 12:00 - PHP
Generate tags color automatically based on the tag text
<?php
class Tag {
public static function tagColor($tag) {
$m = md5(strtolower($tag));
$h = (floor(hexdec(substr($m, 0, 4)) / 65535 * 359) % 29) * 29;
$s = (hexdec(substr($m, 4, 2)) % 32) + 69;
$l = (hexdec(substr($m, 6, 2)) % 16) + 75;
return 'hsl(' . $h . ', ' . $s .'%, ' . $l . '%)';
}
}