Generate color code from a string.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
LICENSE
README.md
composer.json

README.md

text-to-color

Generate color code from a string.

How to use

  1. install using composer
composer require michimani/text-to-color

and require the main file.

require_once('./txt2color.php');
  1. create the object.
$t2c = new TextToColor();
  1. 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