HashLips / generative-art-opensource

Create generative art by using the canvas api and node js, feel free to contribute to this repo with new ideas.
MIT License
1.36k stars 692 forks source link

Stacking artworks #3

Closed euginium closed 3 years ago

euginium commented 3 years ago

This issue is also found in the first version of the program .

The first edition of the image is clean. However, when it come to the 2nd edition of the image, the 1st edition can still be seen beneath the 2nd edition.

How do we fix it?

HashLips commented 3 years ago

You will need to clean the ctx everytime you start to create a new edition in the loop function.

On Thu, 26 Aug 2021, 12:46 pm Euginium @.***> wrote:

This issue is also found in the first version of the program .

The first edition of the image is clean. However, when it come to the 2nd edition of the image, the 1st edition can still be seen beneath the 2nd edition.

How do we fix it?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/HashLips/generative-art-opensource/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVAXZL3EBRAYBS6DDPTUBXTT6YLPDANCNFSM5C3CG7FA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

euginium commented 3 years ago

How do I clear it? Sorry I'm a newbie Thanks for the help.

HashLips commented 3 years ago

No worries. You can run this after the image has saved.

ctx.clearRect(0,0,width,height);

On Thu, 26 Aug 2021, 1:12 pm Euginium @.***> wrote:

How do I clear it? Sorry I'm a newbie Thanks for the help.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HashLips/generative-art-opensource/issues/3#issuecomment-906312147, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVAXZLYPCWR335LV5ZU4V2TT6YOR5ANCNFSM5C3CG7FA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

HashLips commented 3 years ago

Change:

let mappedDnaToLayers = _layers.map((layer) => { let selectedElement = layer.elements[parseInt(DnaSegment) % layer.elements.length]; return { location: layer.location, position: layer.position, size: layer.size, selectedElement: selectedElement, }; });

To:

let mappedDnaToLayers = _layers.map((layer, index) => { let selectedElement = layer.elements[parseInt(DnaSegment[index]) % layer.elements.length]; return { location: layer.location, position: layer.position, size: layer.size, selectedElement: selectedElement, }; });