You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rad, *and long*, package name.. huh? Sorry. I'm not very good with names.
25
25
26
26
## Usage
27
27
As with installation, usage is quite simple. Generating a image is done by running:
28
-
```php
28
+
````php
29
29
$avatar = new LasseRafn\InitialAvatarGenerator\InitialAvatar();
30
30
31
31
$image = $avatar->name('Lasse Rafn')->generate();
32
-
```
32
+
````
33
33
34
34
Thats it! The method will return a instance of [Image from Intervention](https://github.com/Intervention/image) so you can stream, download or even encode the image:
35
-
```php
35
+
````php
36
36
return $image->stream('png', 100);
37
-
```
37
+
````
38
38
You can also just pass along the initials, and it will use those. Should you just include a first name, it will use the first two letters of it.
39
39
40
40
## Supported methods and parameters
41
41
Of cause, passing a name is not the only thing this sweet thing does!
You can simply use ->cache() and it will set cache to 60 minutes, but you can also say ->cache(180) to cache for 180 minutes.
84
84
85
85
### Length - default: 2
86
-
```php
86
+
````php
87
87
$image = $avatar->name('John Doe Johnson')->length(3)->generate(); // 3 letters = JDJ
88
-
```
88
+
````
89
89
90
90
### Rounded - default: false
91
-
```php
91
+
````php
92
92
$image = $avatar->rounded()->generate();
93
-
```
93
+
````
94
94
95
-
I recommend that you simply **do not** enable rounding, as the edges can become way too sharp, compared to simply setting `border-radius: 100%` on the image (see below)
95
+
I recommend that you simply **do not** enable rounding, as the edges are way too sharp, compared to simply setting ````border-radius: 100%```` on the image (see below)
96
96
97
97
### Font Size - default: 0.5
98
-
```php
98
+
````php
99
99
$image = $avatar->fontSize(0.25)->generate(); // Font will be 25% of image size.
100
-
```
100
+
````
101
101
If the Image size is 50px and fontSize is 0.5, the font size will be 25px.
102
102
103
103
## Chaining it all together
104
104
We will not use the ->font() method in this example; as I like the regular one.
0 commit comments