Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robinn1/svg-avatar
Create a unique avatar for each user based on their name.
https://github.com/robinn1/svg-avatar
avatar avatar-generator svg
Last synced: about 8 hours ago
JSON representation
Create a unique avatar for each user based on their name.
- Host: GitHub
- URL: https://github.com/robinn1/svg-avatar
- Owner: RobiNN1
- License: mit
- Created: 2022-10-29T21:29:08.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-27T10:35:04.000Z (3 months ago)
- Last Synced: 2024-08-27T11:50:00.986Z (3 months ago)
- Topics: avatar, avatar-generator, svg
- Language: PHP
- Homepage:
- Size: 58.6 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
SVG avatar generator
Create a unique avatar for each user based on their name.
![Visitor Badge](https://visitor-badge.laobi.icu/badge?page_id=RobiNN1.SVG-Avatar)
## Installation
```
composer require robinn/svg-avatar
```## Usage
```php
use RobiNN\SVGAvatar\SVGAvatar;$avatar = new SVGAvatar();
echo $avatar->name('RobiNN');
```> If you do not set a name, the user icon will be displayed.
> This can be useful for guests.## Methods
```php
// Custom size, default is 48px.
$avatar->size(64);// Display as a circle.
$avatar->circle();// Border radius.
$avatar->radius(10);// CSS class.
$avatar->class('avatar');// Custom colors. By default, background colors are generated from name.
$avatar->setColors(['#f44336', '#e91e63', '#9c27b0', '#673ab7', '#3f51b5', '#2196f3',]);
// You can set the text color if needed. The default is 'auto' which sets '#fff' or '#000'.
$avatar->setColors([...], '#000');// Color brightness, between 0-100, default is 50. Doesn't work with setColors().
$avatar->brightness(80);// Color uniqueness, between 1-10, 3 is default. Doesn't work with setColors().
$avatar->uniqueness(7);// Output as base64
$avatar->toBase64();
```## Requirements
- PHP >= 8.2
- mbstring extension