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

Changing editionSize will cause error in node.js #95

Open norasyeezys opened 2 years ago

norasyeezys commented 2 years ago

I changed editionSize from 10 to 20, and I got this error. It works fine with 10.

##################

Generative Art

- Create your NFT collection

##################

start creating NFTs.

creating NFT 1 of 20

TypeError: Cannot read properties of undefined (reading 'length') at C:[%directory]\generative-art-opensource-main\index.js:133:77 at Array.forEach () at createDna (C:[%directory]\generative-art-opensource-main\index.js:132:11) at startCreating (C:[%directory]\generative-art-opensource-main\index.js:200:18) at Object. (C:[%directory]\generative-art-opensource-main\index.js:249:1) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)

bgastaldo commented 2 years ago

Same issue, been trying to figure it out

EclecticDeviant commented 2 years ago

Also been trying to hammer this one out. Everytime I change the Edition Size beyond 11, it throws this error. It does 11 and less, for me at least, without issue.

walkingeclipse commented 2 years ago

I think I figured it out. Go to config.js Then to line 129: const editionSize = 10; Change the number to the total number of NFT's you want to generate.

Then make sure to adjust your rarities. You can do this starting on line 135 and ending on line 138: let rarityWeights = [ addRarity('super_rare', 1, 1), addRarity('rare', 2, 5), addRarity('original', 5, 10)

Adjust the numbers so the rarities match the total number of NFT's you want to create.

Let me know if this helps. I was running the code and it would only create 10 editions. After doing some digging I figured it out and was able to do 15 editions without an error.

norasyeezys commented 2 years ago

I think I figured it out. Go to config.js Then to line 129: const editionSize = 10; Change the number to the total number of NFT's you want to generate.

Then make sure to adjust your rarities. You can do this starting on line 135 and ending on line 138: let rarityWeights = [ addRarity('super_rare', 1, 1), addRarity('rare', 2, 5), addRarity('original', 5, 10)

Adjust the numbers so the rarities match the total number of NFT's you want to create.

Let me know if this helps. I was running the code and it would only create 10 editions. After doing some digging I figured it out and was able to do 15 editions without an error.

After playing with numbers, I got it to work for a bit, and then it gave me an infinite loop.

laygir commented 2 years ago

@WalkingEclipse indeed that's the way to go.

The second and third parameters are from and to. Meaning the length of range that rarity should be applied. And the provided range lengths must match the value of editionSize set in the config otherwise will throw an error while generating the outputs.

For example;

const editionSize = 100;

let rarityWeights = [
  addRarity('super_rare', 1, 10),
  addRarity('rare', 10, 40),
  addRarity('original', 40, 100)
];

from 1 to 10 will be super rare – 10 images from 10 to 40 will be rare – 30 images from 40 to 100 will be original – 60 images

Maybe another detail: by changing the order of addRarity you can control if the first x to y is a certain rarity. Mind that it is inverted though. In the above example the last 10 images will be super_rare in the output folder.

JimFit77 commented 2 years ago

how i remove numbers from the final image? also how i surpass infinite loop?