From 6e2b86beb697a6e60d773c7fb2b032ced5912da7 Mon Sep 17 00:00:00 2001 From: NoodleOfDeath Date: Thu, 19 May 2022 12:00:44 -0400 Subject: [PATCH 1/3] feat: ability to specify an edition offset in the first layer configuration only --- README.md | 35 ++++++++++++++++++++++++++++++++++- src/config.js | 3 ++- src/main.js | 23 ++++++++++++++++++----- 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 98a393c2e..6b1804d6f 100644 --- a/README.md +++ b/README.md @@ -101,10 +101,43 @@ const layerConfigurations = [ ]; ``` -Update your `format` size, ie the outputted image size, and the `growEditionSizeTo` on each `layerConfigurations` object, which is the amount of variation outputted. +Update your `format` size, (i.e. the outputted image size, and the `growEditionSizeTo` on each `layerConfigurations` object), which is the amount of variation outputted. You can mix up the `layerConfigurations` order on how the images are saved by setting the variable `shuffleLayerConfigurations` in the `config.js` file to true. It is false by default and will save all images in numerical order. +If you want a custom edition offset for your layer configuration, you can specify an `editionOffset` in the _first_ `layerConfiguration` object. + +_Example:_ You already generated collection of `120` NFTs and want to start generating more NFTs as a continuation of the collection. + +```js +const layerConfigurations = [ + { + editionOffset: 121, // start from 121 + growEditionSizeTo: 100, // will generate 100 nfts named 121 - 220 + layersOrder: [ + { name: "Head" }, + { name: "Mouth" }, + { name: "Eyes" }, + { name: "Eyeswear" }, + { name: "Headwear" }, + ], + }, + { + // Creates an additional 100 artworks numbered 221 - 370 + growEditionSizeTo: 150, + layersOrder: [ + { name: "Background" }, + { name: "Head" }, + { name: "Eyes" }, + { name: "Mouth" }, + { name: "Eyeswear" }, + { name: "Headwear" }, + { name: "AlienHeadwear" }, + ], + }, +]; +``` + If you want to have logs to debug and see what is happening when you generate images you can set the variable `debugLogs` in the `config.js` file to true. It is false by default, so you will only see general logs. If you want to play around with different blending modes, you can add a `blend: MODE.colorBurn` field to the layersOrder `options` object. diff --git a/src/config.js b/src/config.js index c46d867a0..42d5bd396 100644 --- a/src/config.js +++ b/src/config.js @@ -24,7 +24,8 @@ const solanaMetadata = { // If you have selected Solana then the collection starts from 0 automatically const layerConfigurations = [ { - growEditionSizeTo: 5, + editionOffset: 11, // You can set this to start numbering from a custom offset + growEditionSizeTo: 15, layersOrder: [ { name: "Background" }, { name: "Eyeball" }, diff --git a/src/main.js b/src/main.js index e9c08dcf2..53fabd51f 100644 --- a/src/main.js +++ b/src/main.js @@ -339,9 +339,18 @@ const startCreating = async () => { let editionCount = 1; let failedCount = 0; let abstractedIndexes = []; + if (layerConfigurations.length === 0) { + console.error("No layer configurations found"); + return; + } + const editionOffset = layerConfigurations[0].editionOffset + ? layerConfigurations[0].editionOffset - 1 + : 0; + const collectionSize = + layerConfigurations[layerConfigurations.length - 1].growEditionSizeTo; for ( - let i = network == NETWORK.sol ? 0 : 1; - i <= layerConfigurations[layerConfigurations.length - 1].growEditionSizeTo; + let i = editionOffset + (network == NETWORK.sol ? 0 : 1); + i <= editionOffset + collectionSize; i++ ) { abstractedIndexes.push(i); @@ -405,9 +414,13 @@ const startCreating = async () => { addMetadata(newDna, abstractedIndexes[0]); saveMetaDataSingleFile(abstractedIndexes[0]); console.log( - `Created edition: ${abstractedIndexes[0]}, with DNA: ${sha1( - newDna - )}` + `${`${ + editionOffset > 0 + ? abstractedIndexes[0] - editionOffset + : abstractedIndexes[0] + }`.padStart(Math.log(collectionSize), " ")} > Created edition: ${ + abstractedIndexes[0] + }, with DNA: ${sha1(newDna)}` ); }); dnaList.add(filterDNAOptions(newDna)); From 3b2a4dc1d2bfca5131defd63e6d0e9227e8f0847 Mon Sep 17 00:00:00 2001 From: NoodleOfDeath Date: Thu, 19 May 2022 12:04:54 -0400 Subject: [PATCH 2/3] fix: comment out editionOffset by default --- src/config.js | 2 +- src/main.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/config.js b/src/config.js index 42d5bd396..86149e95f 100644 --- a/src/config.js +++ b/src/config.js @@ -24,7 +24,7 @@ const solanaMetadata = { // If you have selected Solana then the collection starts from 0 automatically const layerConfigurations = [ { - editionOffset: 11, // You can set this to start numbering from a custom offset + //editionOffset: 11, // You can set this to start numbering from a custom offset other than the default which is 1 growEditionSizeTo: 15, layersOrder: [ { name: "Background" }, diff --git a/src/main.js b/src/main.js index 53fabd51f..c121a2146 100644 --- a/src/main.js +++ b/src/main.js @@ -343,9 +343,11 @@ const startCreating = async () => { console.error("No layer configurations found"); return; } - const editionOffset = layerConfigurations[0].editionOffset - ? layerConfigurations[0].editionOffset - 1 - : 0; + const editionOffset = + layerConfigurations[0].editionOffset && + layerConfigurations[0].editionOffset >= 1 + ? layerConfigurations[0].editionOffset - 1 + : 0; const collectionSize = layerConfigurations[layerConfigurations.length - 1].growEditionSizeTo; for ( From bbaaea72f0a303db0f2bd3f1cde076f95f42fec5 Mon Sep 17 00:00:00 2001 From: NoodleOfDeath Date: Thu, 19 May 2022 12:57:11 -0400 Subject: [PATCH 3/3] fix: throw critical error instead of console error --- src/main.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index c121a2146..3579dfcfc 100644 --- a/src/main.js +++ b/src/main.js @@ -340,8 +340,7 @@ const startCreating = async () => { let failedCount = 0; let abstractedIndexes = []; if (layerConfigurations.length === 0) { - console.error("No layer configurations found"); - return; + throw new Error("No layer configurations found in config.js"); } const editionOffset = layerConfigurations[0].editionOffset &&