Jon-Becker / nft-generator-py

This tool allows users to generate sets of unique images and metadata using weighted layer collections.
MIT License
301 stars 127 forks source link

Layer exclusions based on attribute selection #42

Closed ghost closed 2 years ago

ghost commented 2 years ago

Context: I have 6 trait layers (Background, Body, Eyes, Clothing, Head, Accessory). In the "Clothing" layer I have an attribute named "Grey Hoodie". This attribute contains art that overlaps with the "Head" layer.

For this reason, ideally, the "Head" layer should be excluded when the "Grey Hoodie" is picked.

The current incompatibilities object does not account for this logic atm.

Idea:

Create a layer_incompatibilities object to add "layer exclusions" for certain attributes. This could look something like this:

"layer_incompatibilities": [
    {
      "layer": "Clothing",
      "value": "Grey Hoodie",
      "incompatible_with": ["Head"]
    }
  ],
Jon-Becker commented 2 years ago

Will work on this 🫡

Jon-Becker commented 2 years ago

Resolved in https://github.com/Jon-Becker/nft-generator-py/commit/8c005077ba69206f829acbd3d8424e6d463c465b

A new default optional value has been added to incompatibilities. For example:

"incompatibilities": [
    {
      "layer": "Background",
      "value": "Blue",
      "incompatible_with": ["Python Logo 2"],
      "default": {
        "value": "Default Incompatibility",
        "filename": "./trait-layers/foreground/logo"
      }
    }
  ],

If a blue Background is selected with Python Logo 2, the program will replace it with Default Incompatibility with the image path ./trait-layers/foreground/logo.png.

You can use this with a blank layer to achieve your results. Just make incompatibilities with every item in the incompatible layer, and add a default None with a blank image.