https://github.com/michimani/text-to-color
Generate color code from a string.
https://github.com/michimani/text-to-color
Last synced: 3 months ago
JSON representation
Generate color code from a string.
- Host: GitHub
- URL: https://github.com/michimani/text-to-color
- Owner: michimani
- License: mit
- Created: 2018-07-19T07:38:30.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-04-03T02:47:22.000Z (about 5 years ago)
- Last Synced: 2025-01-04T15:57:16.547Z (5 months ago)
- Language: PHP
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# text-to-color
Generate color code from a string.# How to use
1. install using composer
```console
composer require michimani/text-to-color
```and require the main file.
```php
require_once('./txt2color.php');
```2. create the object.
```php
$t2c = new TextToColor();
```3. call `generateColorHexFromString` function.
```php
$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.```diff
- private $rand_str = 'some strings';
+ private $rand_str = 'other strings';
``````php
$str = 'some string';
$color = $t2c->generateColorHexFromString($str);echo $color;
// #0cf465
```