Are there any complex avatar scripts I could steal or watch?
The project I will be working on will soon need to generate avatars. The generation process will be one where the user can choose different heads, hairstyles, clothes, etc. Some items will also be unavailable at first and will need to be earned or purchased.
I already have a fair idea on how to do this, but since this is a non-trivial amount of code it would be nice to see working code examples. Ideally, I could just take the script and integrate into my page, but just collecting ideas from other people would be fine too.
I'll be working with PHP, but examples in other languages are also welcome.
Added: To clarify, I don't mean a random avatar generator (or one that generates an avatar based on some hash value). The random avatar generator is subtly different from what I've done. In the generator of random avatars from the programmer-artist, much more is said about what is happening. He can carefully select pieces that will not conflict with each other, and he can discard those that cause him trouble.
In my case, the avatar generator looks more like this . The user chooses which head to use, which hairstyle to use, which garment to use, etc. There are even more items, and artists add new ones every time. It is much more difficult to check how things will or will not fit together. Sometimes a more complex blending is required (for example, the hat will have part of it in front of the hair and part of it behind the hair). Etc.
source to share
[ EDIT: Revised answer to updated question]
I think it is primarily a matter of designing the parts accordingly. You have several basic shapes (male, female, tall / small, etc.) for which you have styles (like hair) designed to fit and align. Solving this algorithmically instead is probably a poor choice in terms of workload and probably not required for non-animated shapes.
However, you may need additional alpha / opacity masks or something else to combine the head, hair, and hat.
In addition, these parts must be combined for a layer such as Monster ID.
source to share