HashLips / generative-art-opensource

Create generative art by using the canvas api and node js, feel free to contribute to this repo with new ideas.
MIT License
1.36k stars 695 forks source link

Rarity data: Show percentage of each attribute's occurrence in collection #149

Open jjohnson5253 opened 2 years ago

jjohnson5253 commented 2 years ago

This pull request adds a rarityData.js file that prints out the percentages of each attribute's occurrence throughout the collection. I added the layer name (calling it trait_type) to the metadata to make things easier. This seems to be typical of candy machines like metaplex anyway.

Example output:

Layer: ball
[
  { value: 'red eye ball super rare', percentage: 0 },
  { value: 'eye ball rare', percentage: 20 },
  { value: 'green eye ball rare', percentage: 20 },
  { value: 'grey eye ball', percentage: 10 },
  { value: 'red eye ball', percentage: 50 },
  { value: 'white eye ball', percentage: 0 }
]
Layer: eye color
[
  { value: 'red big super rare', percentage: 0 },
  { value: 'red small super rare', percentage: 20 },
  { value: 'pink big rare', percentage: 0 },
  { value: 'pink small rare', percentage: 10 },
  { value: 'purple big rare', percentage: 10 },
  { value: 'purple small rare', percentage: 30 },
  { value: 'cyan big', percentage: 10 },
  { value: 'cyan small', percentage: 10 },
  { value: 'green big', percentage: 0 },
  { value: 'green small', percentage: 0 },
  { value: 'yellow big', percentage: 10 },
  { value: 'yellow small', percentage: 0 }
]
Layer: iris
[
  { value: 'small super rare', percentage: 10 },
  { value: 'medium rare', percentage: 40 },
  { value: 'large', percentage: 50 }
]
Layer: shine
[
  { value: 'shapes super rare', percentage: 10 },
  { value: 'shapes rare', percentage: 40 },
  { value: 'shapes', percentage: 50 }
]
Layer: bottom lid
[
  { value: 'low bottom super rare', percentage: 10 },
  { value: 'tilted bottom rare', percentage: 40 },
  { value: 'high bottom', percentage: 50 }
]
Layer: top lid
[
  { value: 'tilted top super rare', percentage: 10 },
  { value: 'low top rare', percentage: 40 },
  { value: 'high top', percentage: 50 }
]
NetworkEntity commented 2 years ago

Amazing! Is there a way to impliment this into the Hashlips/Generative-Art-Engine code?

jjohnson5253 commented 2 years ago

You mean HashLips/hashlips_art_engine? Yea I made a pull request there too and it’s currently merged in with main. See the bottom of the readme on that repo

NetworkEntity commented 2 years ago

Exactly what I meant, great work! Thanks!

DanChapp commented 2 years ago

Thanks mate, such a great feature! If I generate the metadata.json and run the util it works, however if I rerun index.js to rebuild my images and jsons (including metadata.json) it returns the previous data, not the updated data. Have you encountered this?

jjohnson5253 commented 2 years ago

@DanChapp Hmm, I don't see that problem for me. Do you mean rarityData.js will use metadata from your initial index.js run? If I rerun index.js and then rarityData.js, the rarity data gets updated. rarityData.js reads in from ./output/_metadata.json so make sure that file is getting overwritten each time you run index.js