michimani / text-to-color
text-to-color is a simple php class for generating color code from text.
0.1.0
2018-07-20 01:34 UTC
Requires
- php: >= 5.6.0
This package is not auto-updated.
Last update: 2025-06-22 08:59:58 UTC
README
Generate color code from a string.
How to use
- install using composer
composer require michimani/text-to-color
and require the main file.
require_once('./txt2color.php');
- create the object.
$t2c = new TextToColor();
- call
generateColorHexFromString
function.
$str = 'some string'; $color = $t2c->generateColorHexFromString($str); echo $color; // #10b51f
Customize
If you want to change algorithm for generating color code, set some string to $rand_str
in TextToColor
class.
- private $rand_str = 'some strings'; + private $rand_str = 'other strings';
$str = 'some string'; $color = $t2c->generateColorHexFromString($str); echo $color; // #0cf465