| 91 | // this maps the layer information to the generated dna and prepares it for |
| 92 | // drawing on a canvas |
| 93 | const constructLayerToDna = (_dna = [], _layers = [], _rarity) => { |
| 94 | let mappedDnaToLayers = _layers.map((layer, index) => { |
| 95 | let selectedElement = layer.elements.find(element => element.id === _dna[index]); |
| 96 | return { |
| 97 | location: layer.location, |
| 98 | position: layer.position, |
| 99 | size: layer.size, |
| 100 | selectedElement: {...selectedElement, rarity: _rarity }, |
| 101 | }; |
| 102 | }); |
| 103 | return mappedDnaToLayers; |
| 104 | }; |
| 105 | |
| 106 | // check if the given dna is contained within the given dnaList |
| 107 | // return true if it is, indicating that this dna is already in use and should be recalculated |