MCPcopy Create free account
hub / github.com/HashLips/generative-art-opensource / constructLayerToDna

Function constructLayerToDna

index.js:93–104  ·  view source on GitHub ↗
(_dna = [], _layers = [], _rarity)

Source from the content-addressed store, hash-verified

91// this maps the layer information to the generated dna and prepares it for
92// drawing on a canvas
93const 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

Callers 1

startCreatingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected