Generator of avatar
In Central Maven :
<dependency>
<groupId>com.talanlabs</groupId>
<artifactId>avatar-generator</artifactId>
<version>1.1.0</version>
</dependency>
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 |
Example 1 :
Avatar avatar = TriangleAvatar.newAvatarBuilder().build();
avatar.create(123456L);
Source : https://github.com/flouthoc/minBlock.js
Example 1 :
Avatar avatar = SquareAvatar.newAvatarBuilder().build();
avatar.create(123456L);
Source : https://github.com/donpark/identicon
Example 1 :
Avatar avatar = IdenticonAvatar.newAvatarBuilder().build();
avatar.create(123456L);
Example 1 :
Avatar avatar = GitHubAvatar.newAvatarBuilder().layers(new ColorPaintBackgroundLayer(Color.WHITE)).build();
avatar.create(123456L);
Example 2 :
Avatar avatar = GitHubAvatar.newAvatarBuilder().build();
avatar.create(123456L);
<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);
Example 2 :
Avatar avatar = CatAvatar.newAvatarBuilder()
.layers(new ShadowLayer(), new RandomColorPaintBackgroundLayer(), new RoundRectMaskLayer())
.padding(8).margin(8).build();
avatar.create(123456L);
<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);
Example 2 :
Avatar avatar = SmileyAvatar.newEyeMouthAvatarBuilder().build();
avatar.create(123456L);
Example 3 :
Avatar avatar = SmileyAvatar.newGhostAvatarBuilder().build();
avatar.create(123456L);
Example 4 :
Avatar avatar = SmileyAvatar.newDefaultAvatarBuilder().build();
avatar.create(123456L);
<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);
Example 2 :
Avatar avatar = EightBitAvatar.newFemaleAvatarBuilder().build();
avatar.create(123456L);
// 建立映像檔
docker build --rm -t avatar-rest-api .
// 映像檔建立 refernece
docker tag avatar-rest-api rockexe0000/avatar-rest-api
// 映像檔推送到 docker hub
docker image push rockexe0000/avatar-rest-api
// 啟動容器
docker container run -d -p 8080:8080 rockexe0000/avatar-rest-api
http://localhost:8080/avatar/cat?id=aaa&width=128&height=128
http://localhost:8080/avatar/eightbit/male?id=aaa
http://localhost:8080/avatar/eightbit/female?id=aaa
http://localhost:8080/avatar/github?id=aaa
http://localhost:8080/avatar/identicon?id=aaa
http://localhost:8080/avatar/smiley/accessories?id=aaa
http://localhost:8080/avatar/smiley/eyemouth?id=aaa
http://localhost:8080/avatar/smiley/ghost?id=aaa
http://localhost:8080/avatar/smiley/default?id=aaa
http://localhost:8080/avatar/square?id=aaa
http://localhost:8080/avatar/triangle?id=aaa
mkdir k8s && cd k8s
// 建立 deployment 的 yaml
kubectl create deployment avatar-rest-api-demo --image=rockexe0000/avatar-rest-api --dry-run -o yaml > avatar-rest-api-demo.yaml
// 新增資源
kubectl apply -f avatar-rest-api-demo.yaml
kubectl get pods
kubectl get pods -o wide
// 服務縮放成3個
kubectl scale deployment avatar-rest-api-demo --replicas=3
// 服務對外
kubectl expose deployment avatar-rest-api-demo --port=8111 --target-port=8080 --type=NodePort
// 查 services 的 port
kubectl get svc
// test
curl http://localhost:30895/avatar/cat?id=aaa&width=128&height=128
kubectl get pod
// delete deployment
kubectl delete deployment avatar-rest-api-demo
// delete service
kubectl delete service avatar-rest-api-demo
// delete pod
kubectl delete pod avatar-rest-api-demo-7c456674f5-q825w
vim avatar-rest-api-demo.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: avatar-rest-api-demo
name: avatar-rest-api-demo
spec:
replicas: 1
selector:
matchLabels:
app: avatar-rest-api-demo
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: avatar-rest-api-demo
spec:
containers:
- image: rockexe0000/avatar-rest-api
name: avatar-rest-api
resources: {}
status: {}