Comments (4)
Hi, thank you for this! I'll add this into it 👍 would you care to do a PR?
sorry for the late response
from php-initial-avatar-generator.
Hey @LasseRafn You can use the colors from https://gist.github.com/HRankit/5fc47a4dc534a4a769992e05b86ab43d . It has most of material design colors.
from php-initial-avatar-generator.
maybe this:
function textToColor($str)
{
if (empty($str)) {
return false;
}
$color = '#';
$hash = 0;
for ($i = 0; $i < mb_strlen($str); $i++) {
$char = mb_substr($str, $i, 1, 'UTF-8');
$hash = hexdec(bin2hex($char)) + (($hash << 5) - $hash);
}
for ($i = 0; $i < 3; $i++) {
$char_hash = ($hash >> $i * 2) & 0xFF;
$char_hash_hex = dechex($char_hash);
$col = '00' . $char_hash_hex;
$color .= mb_substr($col, -2);
}
return $color;
}
from php-initial-avatar-generator.
Hi @LasseRafn, I don't know if you already have any function in your script to load the color by name but anyway I created a function, see below:
from php-initial-avatar-generator.
Related Issues (20)
- Document `keepCase`
- Document use-case against CSS HOT 1
- No way to use Imagick as driver? HOT 4
- Broken Return HOT 3
- Result output HOT 6
- Turkish Characters
- Saving the generated image HOT 2
- Laravel use HOT 9
- Laravel Wrapper HOT 1
- SVG support ? HOT 2
- Set image height HOT 1
- Installation failed HOT 1
- Gradient Colors HOT 1
- [FEAT] Emoji/emoticon support
- Initials are not centered HOT 1
- [Regression] SVGs not resizing in IE11
- PHP 8 Support HOT 11
- FontAwesome only user icon works HOT 1
- Deprecation Notice: Dynamic property creation in InitialAvatar.php with php 8.2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-initial-avatar-generator.