We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is your feature request related to a problem? Please describe.
For example I want to add default avatar from username and it should be consistent when generated twice.
Describe the solution you'd like
username = "chiliec" stableAvatar = pa.Avatar.random(from=username)
The text was updated successfully, but these errors were encountered:
the functionality you're looking for can already be achieved using the current version of the package, you just need to write a couple of functions:
import python_avatars as pa def get_nth_enum_item(n, e): items = e.get_all() return items[n % len(items)] def avatar_from_username(username): username_hash = hash(username) return pa.Avatar( style=get_nth_enum_item(username_hash, pa.AvatarStyle), background_color=get_nth_enum_item(username_hash, pa.BackgroundColor), top=get_nth_enum_item(username_hash, pa.TopType), hat_color=get_nth_enum_item(username_hash, pa.ClothingColor), eyebrows=get_nth_enum_item(username_hash, pa.EyebrowType), eyes=get_nth_enum_item(username_hash, pa.EyeType), nose=get_nth_enum_item(username_hash, pa.NoseType), mouth=get_nth_enum_item(username_hash, pa.MouthType), facial_hair=get_nth_enum_item(username_hash, pa.FacialHairType), skin_color=get_nth_enum_item(username_hash, pa.SkinColor), hair_color=get_nth_enum_item(username_hash, pa.HairColor), facial_hair_color=get_nth_enum_item(username_hash, pa.HairColor), accessory=get_nth_enum_item(username_hash, pa.AccessoryType), clothing=get_nth_enum_item(username_hash, pa.ClothingType), clothing_color=get_nth_enum_item(username_hash, pa.ClothingColor), shirt_graphic=get_nth_enum_item(username_hash, pa.ClothingGraphic), shirt_text=username, title=f"Avatar for {username}", )
And avatar_from_username('chiliec') should always generate something like this:
avatar_from_username('chiliec')
Sorry, something went wrong.
@ibonn thanks a lot! What do you think about include this feature inside package?
Hmmm... probably not. I may create a separate branch and keep this solution there just in case (I might change my mind in the future)
ibonn
No branches or pull requests
Is your feature request related to a problem? Please describe.
For example I want to add default avatar from username and it should be consistent when generated twice.
Describe the solution you'd like
The text was updated successfully, but these errors were encountered: