()
| 335 | } |
| 336 | |
| 337 | const startCreating = async () => { |
| 338 | let layerConfigIndex = 0; |
| 339 | let editionCount = 1; |
| 340 | let failedCount = 0; |
| 341 | let abstractedIndexes = []; |
| 342 | for ( |
| 343 | let i = network == NETWORK.sol ? 0 : 1; |
| 344 | i <= layerConfigurations[layerConfigurations.length - 1].growEditionSizeTo; |
| 345 | i++ |
| 346 | ) { |
| 347 | abstractedIndexes.push(i); |
| 348 | } |
| 349 | if (shuffleLayerConfigurations) { |
| 350 | abstractedIndexes = shuffle(abstractedIndexes); |
| 351 | } |
| 352 | debugLogs |
| 353 | ? console.log("Editions left to create: ", abstractedIndexes) |
| 354 | : null; |
| 355 | while (layerConfigIndex < layerConfigurations.length) { |
| 356 | const layers = layersSetup( |
| 357 | layerConfigurations[layerConfigIndex].layersOrder |
| 358 | ); |
| 359 | while ( |
| 360 | editionCount <= layerConfigurations[layerConfigIndex].growEditionSizeTo |
| 361 | ) { |
| 362 | let newDna = createDna(layers); |
| 363 | if (isDnaUnique(dnaList, newDna)) { |
| 364 | let results = constructLayerToDna(newDna, layers); |
| 365 | let loadedElements = []; |
| 366 | |
| 367 | results.forEach((layer) => { |
| 368 | loadedElements.push(loadLayerImg(layer)); |
| 369 | }); |
| 370 | |
| 371 | await Promise.all(loadedElements).then((renderObjectArray) => { |
| 372 | debugLogs ? console.log("Clearing canvas") : null; |
| 373 | ctx.clearRect(0, 0, format.width, format.height); |
| 374 | if (gif.export) { |
| 375 | hashlipsGiffer = new HashlipsGiffer( |
| 376 | canvas, |
| 377 | ctx, |
| 378 | `${buildDir}/gifs/${abstractedIndexes[0]}.gif`, |
| 379 | gif.repeat, |
| 380 | gif.quality, |
| 381 | gif.delay |
| 382 | ); |
| 383 | hashlipsGiffer.start(); |
| 384 | } |
| 385 | if (background.generate) { |
| 386 | drawBackground(); |
| 387 | } |
| 388 | renderObjectArray.forEach((renderObject, index) => { |
| 389 | drawElement( |
| 390 | renderObject, |
| 391 | index, |
| 392 | layerConfigurations[layerConfigIndex].layersOrder.length |
| 393 | ); |
| 394 | if (gif.export) { |
no test coverage detected