Skip to content

gabrie-allaigre/avatar-generator

Repository files navigation

Avatar Generator

Generator of avatar

image

Dependency

In Central Maven :

<dependency>
    <groupId>com.talanlabs</groupId>
    <artifactId>avatar-generator</artifactId>
    <version>1.1.0</version>
</dependency>

Usage

Use Avatar avatar = Avatar.newBuilder()...build()

Configuration :

Method Description
elementRegistry(ElementRegistry elementRegistry) Registry elements & groups
size(int width, int height) Size of final image
padding(int padding) Add padding in pixel of elements
margin(int margin) Add marge in pixel
layers(ILayer... layers) Add layers to apply in elements
color(Color color) Colorize all elements
colorizeFunction(IColorizeFunction colorizeFunction) Colorize elements
cache(ICache cache) Use cache

Create :

Use avatar.create...

Method Description
BufferedImage create(long code) Create Avatar as BufferedImage
byte[] createAsPngBytes(long code) Create Avatar as Png byte array
void createAsPngToFile(long code, File file) Create Avatar as Png to file

Predefined avatar

Triangle

Example 1 :

Avatar avatar = TriangleAvatar.newAvatarBuilder().build();

avatar.create(123456L);

Sample Triangle1

image

Square

Source : https://github.com/flouthoc/minBlock.js

Example 1 :

Avatar avatar = SquareAvatar.newAvatarBuilder().build();

avatar.create(123456L);

Sample Square1

image

Identicon

Source : https://github.com/donpark/identicon

Example 1 :

Avatar avatar = IdenticonAvatar.newAvatarBuilder().build();

avatar.create(123456L);

Sample Identicon1

image

GitHub

Example 1 :

Avatar avatar = GitHubAvatar.newAvatarBuilder().layers(new ColorPaintBackgroundLayer(Color.WHITE)).build();

avatar.create(123456L);

Sample GitHub1

image

Example 2 :

Avatar avatar = GitHubAvatar.newAvatarBuilder().build();

avatar.create(123456L);

Sample GitHub2

image

Cat

<dependency>
    <groupId>com.talanlabs</groupId>
    <artifactId>avatar-generator-cat</artifactId>
    <version>1.1.0</version>
</dependency>

Images sources : CC-By 4.0 attribution: David Revoy https://framagit.org/Deevad/cat-avatar-generator

Example 1 :

Avatar avatar = CatAvatar.newAvatarBuilder().build();

avatar.create(123456L);

Sample Cat1

image

Example 2 :

Avatar avatar = CatAvatar.newAvatarBuilder()
    .layers(new ShadowLayer(), new RandomColorPaintBackgroundLayer(), new RoundRectMaskLayer())
    .padding(8).margin(8).build();

avatar.create(123456L);

Sample Cat2

image

Smiley

<dependency>
    <groupId>com.talanlabs</groupId>
    <artifactId>avatar-generator-smiley</artifactId>
    <version>1.1.0</version>
</dependency>

Example 1 :

Avatar avatar = SmileyAvatar.newAccessoriesAvatarBuilder().build();

avatar.create(123456L);

Sample Smiley1

image

Example 2 :

Avatar avatar = SmileyAvatar.newEyeMouthAvatarBuilder().build();

avatar.create(123456L);

Sample Smiley2

image

Example 3 :

Avatar avatar = SmileyAvatar.newGhostAvatarBuilder().build();

avatar.create(123456L);

Sample Smiley3

image

Example 4 :

Avatar avatar = SmileyAvatar.newDefaultAvatarBuilder().build();

avatar.create(123456L);

Sample Smiley4

image

8 bit

<dependency>
    <groupId>com.talanlabs</groupId>
    <artifactId>avatar-generator-8bit</artifactId>
    <version>1.1.0</version>
</dependency>

Images sources : https://github.com/o1egl/govatar

Example 1 :

Avatar avatar = EightBitAvatar.newMaleAvatarBuilder().build();

avatar.create(123456L);

Sample 8bit1

image

Example 2 :

Avatar avatar = EightBitAvatar.newFemaleAvatarBuilder().build();

avatar.create(123456L);

Sample 8bit2

image