Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canvas is not clearing, generative images are overlapping #111

Open
Jubakee opened this issue Nov 25, 2021 · 12 comments
Open

Canvas is not clearing, generative images are overlapping #111

Jubakee opened this issue Nov 25, 2021 · 12 comments

Comments

@Jubakee
Copy link

Jubakee commented Nov 25, 2021

I'm having a problem where the output images are on top of each other.
For Example:
First generated image is wearing a black hat.
Second generated image is generated with no hat but the black hat from image one is still showing.

I have tried : ctx.clearRect(0, 0, canvas.width, canvas.height); but have had no luck as I'm not sure where it has to go.

I have been following the tutorial on youtube Code generative art for NFT in node.js .

Thank you.

@Jubakee Jubakee changed the title Canvas is not clearing, every image seems like is it drawn on top of each other. Canvas is not clearing, generative images are overlapping Nov 25, 2021
@Marssurterre
Copy link

I have the same problem if you found the solution help me 🙏

@Jubakee
Copy link
Author

Jubakee commented Nov 30, 2021 via email

@Marssurterre
Copy link

Marssurterre commented Nov 30, 2021

You place it where exactly (main. Js)?? thank you 🙈

const createFiles = async edition => {
const layers = layersSetup(layersOrder);

let numDupes = 0;
for (let i = 1; i <= edition; i++) {
await layers.forEach(async (layer) => {
await drawLayer(layer, i);
});

@TheAppleDudeCo
Copy link

Hi Guys, I am having this very problem and for some reason, I can not get my head around it and a fix. Please can someone help me?

@Xavi0075
Copy link

Xavi0075 commented Jan 4, 2022

i had this issue, the cause was an extra blank line in the layers list. once i cleaned up my code it went away

@alfreddagenais
Copy link

alfreddagenais commented Jan 15, 2022

I have do a PR to correct this one #145 My solution is more simple. Just reset the canvas to the inital state 😄

@uniteXander
Copy link

I seem to be having this issue as well. When I tried the fix listed I ran into an illegal break statement. Anyone have any fixes for that?
image

@uniteXander
Copy link

if (numDupes > edition) break; //prevents infinite loop if no more unique items can be created
^^^^^

SyntaxError: Illegal break statement
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (C:\Users\chapm\Desktop\generative-art-node-main\index.js:2:53)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
PS C:\Users\chapm\Desktop\generative-art-node-main>

@alfreddagenais
Copy link

alfreddagenais commented Jan 27, 2022

@uniteXander I think you need check your main.js refer to the original file. Check the line 147 of main.js It's a correct way to break into for loop. But in your code you close the for loop at line 139 😃 🤔

@uniteXander
Copy link

I thought I fixed it but I now have the "issue" of it doing the editions twice for some reason. I would like to make a large collection so while it doesnt make the image mess up, I think there is something going on on the back end that I am not seeing.

How do I close a loop?

image

@uniteXander
Copy link

uniteXander commented Jan 27, 2022

@uniteXander I think you need check your main.js refer to the original file. Check the line 147 of main.js It's a correct way to break into for loop. But in your code you close the for loop at line 139 😃 🤔

also @alfreddagenais thank you for responding!

@uniteXander
Copy link

It stopped doing this with your edits! Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants