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 692 forks source link

Defining attributes in MetaData (Addressing Issue #19) #82

Closed monticrysto closed 3 years ago

monticrysto commented 3 years ago

So I used the fix from issue #19 provided by Ponda and it works amazing I just have one question.

Is it possible for the metadata to define each attribute as "traitName: selected.element.name"? I'm working on a macro for uploading collections to opensea in selenium ide and since the "trait_type" and "value" umbrella all config options together there's no way (that i know of) I can get it to recognize each trait individually for filling out the opensea property fields in the macro.

Ideally I'd need my attributes data to look like this:

"attributes": [ {"background":"basic yellow"}, {"eye color":"dark blue"}, {"skin":"tone 8"}, {"hair":"white ponytail"}, {"top":"purple short sleeve"}, {"bottoms":"wrangler blue"}, {"card base":"(C) O Card"}, {"text upper":"basic"}, {"text lower":"noob"}]}

Thank you guys for any help and solutions!!

monticrysto commented 3 years ago

For anyone curious I figured this out!

using the code provided from #19 I just made this minor tweak

const getAttributeForElement = (_element) => { let selectedElement = _element.layer.selectedElement; var parentDir = path.dirname(_element.layer.selectedElement.path); var baseDir = require('path').resolve(parentDir, '..'); var traitName = path.basename(baseDir); let attribute = { [traitName]: selectedElement.name, rarity: selectedElement.rarity, }; return attribute; };

So now the metadata reads

"attributes": [ { "background": "browntoblack" }, { "eye color": "black" }, { "skin": "tone scarred 1" }, { "hair": "black >" }, { "top": "blue short sleeve" }, { "bottoms": "blue jeans" }, { "card base": "(C) sr diamond base" }, { "text upper": "super" }, { "text lower": "marking4" } ]