dapi-labs / react-nice-avatar

react library for generating avatar
https://nice-avatar.wwayne.com
MIT License
1.07k stars 92 forks source link

Seed + config #54

Open peteashworth opened 9 months ago

peteashworth commented 9 months ago

Is there currently a solution to pass in sex + seed. I want to create an avatar off a unique seed but I know the sex. That way the avatar will be sex proper (as I have that info) but then use unique id to generate the other appearance props.

jzombie commented 9 months ago

@peteashworth I'm not the maintainer but you should be able to generate a config w/ only the details that you know, and the rest should be randomized.

const config = genConfig({ sex: "man", hairStyle: "mohawk" })

Edit: I missed the point about the seed, though. My apologies.

jzombie commented 9 months ago

If I'm not mistaken you should be able to do something like this:

const initialConfig = genConfig("hi@dapi.to") 
const config = genConfig({ ...initialConfig, sex: "woman" }) 
peteashworth commented 9 months ago

Thank you @jzombie ; that worked perfectly.

peteashworth commented 9 months ago

Almost; ran it through some tests and found out there is more to selecting the sex as it drives some of the other styling props such as hair style. Which is the need to be able to set some of the props before generating the seed. Short term; ill manually adjust but just a feature idea.


    "sex": "man",
    "faceColor": "#AC6651",
    "earSize": "big",
    "eyeStyle": "smile",
    "noseStyle": "round",
    "mouthStyle": "peace",
    "shirtStyle": "polo",
    "glassesStyle": "none",
    "hairColor": "#F48150",
    "hairStyle": "womanShort",
    "hatStyle": "none",
    "hatColor": "#fff",
    "eyeBrowStyle": "upWoman",
    "shirtColor": "#F4D150",
    "bgColor": "#FC909F"
}```
wwayne commented 9 months ago

Thank you @jzombie and @peteashworth I agree with that, I actually noticed this issue after viewed some use cases. Usually they only have the user's email so I didn't know how to handle such case, let me think more about it and let this issue keep opened at the moment.

arnavvsinghal commented 8 months ago

Almost; ran it through some tests and found out there is more to selecting the sex as it drives some of the other styling props such as hair style. Which is the need to be able to set some of the props before generating the seed. Short term; ill manually adjust but just a feature idea.

    "sex": "man",
    "faceColor": "#AC6651",
    "earSize": "big",
    "eyeStyle": "smile",
    "noseStyle": "round",
    "mouthStyle": "peace",
    "shirtStyle": "polo",
    "glassesStyle": "none",
    "hairColor": "#F48150",
    "hairStyle": "womanShort",
    "hatStyle": "none",
    "hatColor": "#fff",
    "eyeBrowStyle": "upWoman",
    "shirtColor": "#F4D150",
    "bgColor": "#FC909F"
}```

Can you drop in your manual config for female + seed?

swapnil-sudhir commented 8 months ago

quick question, can we make an avatar config save in the database for us to keep that for a user ?

wwayne commented 8 months ago

@swapnil-sudhir Yes the config object returned by getConfig can be saved to a database and retrieved later to be passed to the Avatar component