react-nice-avatar icon indicating copy to clipboard operation
react-nice-avatar copied to clipboard

Seed + config

Open peteashworth opened this issue 1 year ago • 8 comments

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.

peteashworth avatar Feb 14 '24 16:02 peteashworth

@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 avatar Feb 14 '24 16:02 jzombie

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

const initialConfig = genConfig("[email protected]") 
const config = genConfig({ ...initialConfig, sex: "woman" }) 

jzombie avatar Feb 14 '24 16:02 jzombie

Thank you @jzombie ; that worked perfectly.

peteashworth avatar Feb 14 '24 17:02 peteashworth

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"
}```

peteashworth avatar Feb 14 '24 17:02 peteashworth

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.

wwayne avatar Feb 15 '24 02:02 wwayne

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?

arnavvsinghal avatar Mar 05 '24 13:03 arnavvsinghal

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

swapnil-sudhir avatar Mar 08 '24 02:03 swapnil-sudhir

@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

wwayne avatar Mar 08 '24 02:03 wwayne