From 5e7d41ef1ad8110a0c2f9b4130674e28401b1877 Mon Sep 17 00:00:00 2001 From: sk33z3r Date: Tue, 12 Jul 2022 12:53:37 -0400 Subject: [PATCH 01/10] chore: update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4fd2865..f2bc117 100755 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ ### Custom ### +companion/ all-traits.json gen-stats.json traits.json From 9c209acc5c47ec2bad6b7edd29ce87b29bc1f0e2 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 30 Jun 2022 00:02:33 -0700 Subject: [PATCH 02/10] fix[ui]: float comparison to avoid rounding errors in rarities validation --- php/edit/3.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/edit/3.php b/php/edit/3.php index a7dc28e..31aca85 100755 --- a/php/edit/3.php +++ b/php/edit/3.php @@ -49,7 +49,7 @@ console.log(t); const errorH3 = document.getElementById(`trait${t}_error`); const sum = rarities[t].reduce((cum, el) => cum + el, 0); - if (sum !== 100) { + if (abs(sum - 100) > 1e-6) { // Float comparison for sum == 100, avoids rounding errors errorH3.innerHTML = `The rarity percentages should add up to 100% (not ${sum}%)`; errorH3.hidden = false; window.location.hash = `trait${t}`; From 78be6f98da0bb752668cde1de06754580460b90f Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 30 Jun 2022 00:04:09 -0700 Subject: [PATCH 03/10] add[ui]: add layer rarity to collection edit page --- php/edit/3.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/php/edit/3.php b/php/edit/3.php index 31aca85..ff141bd 100755 --- a/php/edit/3.php +++ b/php/edit/3.php @@ -34,21 +34,24 @@ let rarities = []; // Build rarities array (rarities[t][v] = r => Trair 't', variation 'v' has rarity 'r'%) for (const input of form) { - const match = input.id.match(/trait(\d+)_(\d+)_rarity/); + const match = input.id.match(/trait(\d+)_(\d+|empty)_rarity/); if (match) { const [/*ignore*/, trait, variation] = match; if (rarities[trait] === undefined) { rarities[trait] = []; } - rarities[trait][variation-1] = parseFloat(input.value); + if (variation === 'empty') { + rarities[trait]['empty'] = parseFloat(input.value); + } else { + rarities[trait][variation-1] = parseFloat(input.value); + } } } // Iterate through rarities backwards and make sure the sum is 100, or display message const first_t = (rarities[0] === undefined) ? 1 : 0; for (let t = rarities.length - 1; t >= first_t; t--) { - console.log(t); const errorH3 = document.getElementById(`trait${t}_error`); - const sum = rarities[t].reduce((cum, el) => cum + el, 0); + const sum = rarities[t].reduce((cum, el) => cum + el, 0) + rarities[t]['empty']; if (abs(sum - 100) > 1e-6) { // Float comparison for sum == 100, avoids rounding errors errorH3.innerHTML = `The rarity percentages should add up to 100% (not ${sum}%)`; errorH3.hidden = false; @@ -84,8 +87,12 @@ while ($s <= $new_traits['trait_count']) { if ($t == 0 and $new_traits['background_color'] === true) { unset($layer); + $weights_empty = false; if (($traits['background_color'] === true) and isset($traits['image_layers'][$s])) { $layer = $traits["image_layers"][$s]; + if (isset($layer['weights_total']) && isset($layer['weights'])) { + $weights_empty = $layer['weights_total'] - array_sum($layer['weights']); + } } ?>

Setup Background Colors:

@@ -123,8 +130,12 @@ $s_offset = 0; if ($traits['background_color'] === false) { $s_offset = -1; } unset($layer); + $weights_empty = false; if (isset($traits['image_layers'][$s + $s_offset])) { $layer = $traits["image_layers"][$s + $s_offset]; + if (isset($layer['weights_total']) && isset($layer['weights'])) { + $weights_empty = $layer['weights_total'] - array_sum($layer['weights']); + } } ?>

Setup "" Trait:

@@ -157,6 +168,15 @@ +
+

Skip layer:

+
+ +  % +
+
+ @@ -182,6 +202,7 @@ array_push($new_traits["image_layers"][$t]['weights'], (float)$_POST["trait${trait_var}_rarity"]); $v = $v + 1; } + $new_traits["image_layers"][$t]['weights_total'] = (float)$_POST["trait${s}_empty_rarity"] + array_sum($new_traits["image_layers"][$t]['weights']); // Should be 100 } else { $v = 1; $new_traits["image_layers"][$t]['filenames'] = array(); @@ -189,7 +210,7 @@ while ($v <= $new_traits['image_layers'][$t]['variations']) { $trait_var = $s . "_" . $v; $var_name = $_POST["trait${trait_var}_name"]; - $var_weight =(float)$_POST["trait${trait_var}_rarity"]; + $var_weight = (float)$_POST["trait${trait_var}_rarity"]; if (isset($_FILES["trait${trait_var}_file"])) { // New file was uploaded $filename = $_FILES["trait${trait_var}_file"]['name']; @@ -205,6 +226,7 @@ array_push($new_traits["image_layers"][$t]['weights'], $var_weight); // Add weights to weight array $v = $v + 1; } + $new_traits["image_layers"][$t]['weights_total'] = (float)$_POST["trait${s}_empty_rarity"] + array_sum($new_traits["image_layers"][$t]['weights']); // Should be 100 } $t = $t + 1; $s = $s + 1; From 5aa3accf976c1e309a63ff04716f51b191411ea0 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 30 Jun 2022 00:05:02 -0700 Subject: [PATCH 04/10] chore[ui]: improve readability of variations to collection edit page --- css/main.css | 14 ++++++++++++-- php/edit/3.php | 42 +++++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/css/main.css b/css/main.css index 578fa24..3aa9f85 100755 --- a/css/main.css +++ b/css/main.css @@ -47,10 +47,10 @@ h3 { } h4 { - width: 500px; + width: 100%; text-align: left; font-size: 16px; - margin: 10px 0; + margin: 10px 0 0 10px; } a, @@ -76,6 +76,16 @@ form { justify-content: space-around; } +hr { + width: calc(100% + 10px); + height: 8px; + margin: -8px 0 8px 0; + border: 1px solid #22243a; + border-top: none; + border-radius: 0 0 20px 20px; + box-shadow: 0 3px 5px #22243a; +} + .content { margin: 10px 0; width: 950px; diff --git a/php/edit/3.php b/php/edit/3.php index ff141bd..5880493 100755 --- a/php/edit/3.php +++ b/php/edit/3.php @@ -85,7 +85,7 @@

Setup Background Colors:

- -

Color #:

-
- -
-
-
-
-  % -
-
-
- +
+

Color #:

+
+
-
-
- +
+
+
+  % +
+
+
+ +
+
+
+ +
+

Setup "" Trait:

-
+
From 506161433efeaf56ba8ce24b5e0eb18b0a0a620f Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 1 Jul 2022 15:55:23 -0700 Subject: [PATCH 05/10] chore[ui]: move rarity percentage to the right in edit collection page --- php/edit/3.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/php/edit/3.php b/php/edit/3.php index 5880493..b2a99a7 100755 --- a/php/edit/3.php +++ b/php/edit/3.php @@ -113,10 +113,6 @@
-
-
-  % -

@@ -125,6 +121,10 @@
+
+
+  % +

@@ -156,10 +156,6 @@
-
-
-  % -

@@ -168,6 +164,10 @@
+
+
+  % +

Date: Wed, 6 Jul 2022 20:25:39 -0700 Subject: [PATCH 06/10] add[python]: add support for generating images with layer rarity --- python/generate.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/python/generate.py b/python/generate.py index 8bdd349..0ffd321 100755 --- a/python/generate.py +++ b/python/generate.py @@ -28,9 +28,9 @@ def __init__(self, layers: list, seed: str, prev_batches: list, dup_cnt_limit: i self.seed = seed # Keep trait properties only, to make comparison to new image easier self.prev_batches = [] + layer_names = [l["layer_name"] for l in self.layers] for image in prev_batches: - layer_names = [l["layer_name"] for l in self.layers] - self.prev_batches.append({name: image[name] for name in layer_names}) + self.prev_batches.append({name: image[name] for name in layer_names if name in image}) self.this_batch = [] self.dup_cnt_limit = dup_cnt_limit @@ -46,7 +46,9 @@ def create_new_image(self, id: int, dup_cnt: int = 0): # For each trait category, select a random trait based on the weightings for l in self.layers: - new_image[l["layer_name"]] = random.choices(l["names"], l["weights"])[0] + random_variation_name = random.choices(l["variation_names"], l["weights"])[0] + if random_variation_name is not None: + new_image[l["layer_name"]] = random_variation_name if new_image in self.this_batch or new_image in self.prev_batches: if dup_cnt > self.dup_cnt_limit: @@ -118,7 +120,10 @@ def make_directories(paths: utils.Struct, traits: utils.Struct, empty: bool): async def build_and_save_image(paths: utils.Struct, traits: utils.Struct, item: dict, task_id: int): with ImageBuilder(animated_format=traits.animated_format) as img_builder: for l in traits.image_layers: - layer_pretty_name = item[l["layer_name"]] + if l["layer_name"] in item: + layer_pretty_name = item[l["layer_name"]] + else: # Skip empty layers + continue if l["type"] == "filenames": layer_file = os.path.join(l["path"], l["filenames"][layer_pretty_name]) @@ -244,10 +249,17 @@ def main(): first_layer = 0 if traits.background_color else 1 for i, l in enumerate(traits.image_layers): l["type"] = "filenames" if "filenames" in l else "rgba" - l["names"] = list(l[l["type"]].keys()) + l["variation_names"] = list(l[l["type"]].keys()) l["path"] = os.path.join(paths.source, f"layer{(first_layer + i):02}") + if "weights_total" in l: # If weights_total is defined, add a chance to skip the layer + weight_skip = l["weights_total"] - sum(l["weights"]) + l["weights"].append(weight_skip) + l["variation_names"].append(None) + else: # Backward compatibility + l["weights_total"] = sum(l["weights"]) + # Generate the unique combinations based on layer weightings img_gen = ImageGenerator(layers=traits.image_layers, seed=args.seed, prev_batches=prev_batches, dup_cnt_limit=utils.get_variation_cnt(traits.image_layers)) this_batch = img_gen.generate_images(starting_id=starting_id, image_cnt=total_image) @@ -266,13 +278,13 @@ def main(): print("How many of each trait exist?") for l in traits.image_layers: - l["count"] = {item: 0 for item in l["names"]} + l["count"] = {item: 0 for item in l["variation_names"] if item is not None} for image in all_images: - n = 1 for l in traits.image_layers: - item = image[l["layer_name"]] - l["count"][item] += 1 + if l["layer_name"] in image: + item = image[l["layer_name"]] + l["count"][item] += 1 for i, l in enumerate(traits.image_layers): print(f"Layer {i:02}: {l['count']}") From eea25d964eb538ac35f9f77bba9bf4169cc47743 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 6 Jul 2022 20:27:25 -0700 Subject: [PATCH 07/10] add[python]: add support for generating metadata with layer rarity --- python/metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/metadata.py b/python/metadata.py index 5a33b4e..6ac76ef 100755 --- a/python/metadata.py +++ b/python/metadata.py @@ -166,7 +166,7 @@ def main(): # Get trait properties only (remove ID, CID, etc...) layer_names = [l["layer_name"] for l in traits.image_layers] - properties = {name: image[name] for name in layer_names} + properties = {name: image[name] for name in layer_names if name in image} # Create all new info token = { From 1df9d9e57484ba5d6f315a074fe22af558bebaed Mon Sep 17 00:00:00 2001 From: sk33z3r Date: Tue, 12 Jul 2022 13:18:13 -0400 Subject: [PATCH 08/10] chore: bump version --- .version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.version b/.version index e6d5cb8..30290a6 100755 --- a/.version +++ b/.version @@ -1 +1 @@ -1.0.2 \ No newline at end of file +1.1.0a \ No newline at end of file From 3320e7c9e643349d77fe8258b4813eb33588a8e3 Mon Sep 17 00:00:00 2001 From: sk33z3r Date: Tue, 12 Jul 2022 14:00:52 -0400 Subject: [PATCH 09/10] fix: - add layer rarity to setup page - add hr style --- css/main.css | 21 +++++-- php/edit/3.php | 8 ++- php/setup/3.php | 158 +++++++++++++++++++++++++++++++++++------------- 3 files changed, 138 insertions(+), 49 deletions(-) diff --git a/css/main.css b/css/main.css index 3aa9f85..476a338 100755 --- a/css/main.css +++ b/css/main.css @@ -53,6 +53,10 @@ h4 { margin: 10px 0 0 10px; } +h5 { + font-size: 16px; +} + a, a:visited, a:active { @@ -78,14 +82,23 @@ form { hr { width: calc(100% + 10px); - height: 8px; - margin: -8px 0 8px 0; - border: 1px solid #22243a; + height: 5px; + margin: 8px 0; + border: 1px solid #000; +} + +.hrbottom { border-top: none; - border-radius: 0 0 20px 20px; + border-radius: 0; box-shadow: 0 3px 5px #22243a; } +.hrtop { + border-bottom: none; + border-radius: 0; + box-shadow: 0 -3px 5px #22243a; +} + .content { margin: 10px 0; width: 950px; diff --git a/php/edit/3.php b/php/edit/3.php index b2a99a7..3e02366 100755 --- a/php/edit/3.php +++ b/php/edit/3.php @@ -107,6 +107,7 @@ }, $rgb)); $opacity = $layer['rgba'][$var_name][3]; } ?> +

Color #:

@@ -127,7 +128,7 @@
-
+
+

Variation #:

@@ -169,12 +171,12 @@  %
-
+
-

Skip layer:

+
Skip layer:
 % diff --git a/php/setup/3.php b/php/setup/3.php index c339c1e..3e8eecd 100755 --- a/php/setup/3.php +++ b/php/setup/3.php @@ -1,7 +1,7 @@ Trair 't', variation 'v' has rarity 'r'%) for (const input of form) { - const match = input.id.match(/trait(\d+)_(\d+)_rarity/); + const match = input.id.match(/trait(\d+)_(\d+|empty)_rarity/); if (match) { const [/*ignore*/, trait, variation] = match; if (rarities[trait] === undefined) { rarities[trait] = []; } - rarities[trait][variation-1] = parseFloat(input.value); + if (variation === 'empty') { + rarities[trait]['empty'] = parseFloat(input.value); + } else { + rarities[trait][variation-1] = parseFloat(input.value); + } } } // Iterate through rarities backwards and make sure the sum is 100, or display message @@ -46,8 +50,8 @@ for (let t = rarities.length - 1; t >= first_t; t--) { console.log(t); const errorH3 = document.getElementById(`trait${t}_error`); - const sum = rarities[t].reduce((cum, el) => cum + el, 0); - if (sum !== 100) { + const sum = rarities[t].reduce((cum, el) => cum + el, 0) + rarities[t]['empty']; + if (abs(sum - 100) > 1e-6) { // Float comparison for sum == 100, avoids rounding errors errorH3.innerHTML = `The rarity percentages should add up to 100% (not ${sum}%)`; errorH3.hidden = false; window.location.hash = `trait${t}`; @@ -77,61 +81,118 @@ nameInput.value = name; }; - + + if ($t == 0 and $traits['background_color'] === true) { // Background color layer + unset($layer); + $weights_empty = false; + if (($traits['background_color'] === true) and isset($traits['image_layers'][$s])) { + $layer = $traits["image_layers"][$s]; + if (isset($layer['weights_total']) && isset($layer['weights'])) { + $weights_empty = $layer['weights_total'] - array_sum($layer['weights']); + } + } ?>

Setup Background Colors:

- -

Color #:

-
-
-
-
-  % + +
+
+

Color #:

+
+
-
-
- -
-
-
- +
+
+
+ +
+
+
+ +
+
+
+  % +
+
-

Setup "" Trait:

+ } else { // Image layers + $s_offset = 0; + if ($traits['background_color'] === false) { $s_offset = -1; } + unset($layer); + $weights_empty = false; + if (isset($traits['image_layers'][$s + $s_offset])) { + $layer = $traits["image_layers"][$s + $s_offset]; + if (isset($layer['weights_total']) && isset($layer['weights'])) { + $weights_empty = $layer['weights_total'] - array_sum($layer['weights']); + } + } ?> +

Setup "" Trait:

- + +

Variation #:

-
+
+ +
-
-
-  % +
+
+ + + + +
-
-
- +
+
+  %
+
+
+
Skip layer:
+
+ +  % +
+
+ - Date: Tue, 12 Jul 2022 15:33:20 -0400 Subject: [PATCH 10/10] fix: estimated fee warning for mint/transfer --- php/mint.php | 2 +- php/transfer.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/php/mint.php b/php/mint.php index c247f15..026f1ac 100755 --- a/php/mint.php +++ b/php/mint.php @@ -21,7 +21,7 @@ if (empty($_GET['run']) and (empty($_POST['cid']) or empty($_POST['amount']))) { ?>
-

You will not receive estimated fees, this runs the commands with current prices.

+

You will receive estimated fees in the review screen

Current Gas: Gwei

Minter Options

diff --git a/php/transfer.php b/php/transfer.php index f59d924..ba6b43d 100755 --- a/php/transfer.php +++ b/php/transfer.php @@ -21,7 +21,7 @@ if (empty($_GET['run']) and (empty($_POST['wallets']) or empty($_POST['nfts']) or empty($_POST['mode']))) { ?> -

You will not receive estimated fees, this runs the commands with current prices.

+

You will receive estimated fees in the review screen

Current Gas: Gwei

Transfer Options