-
Notifications
You must be signed in to change notification settings - Fork 395
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
Error exporting frames CMD + S #173
Comments
Hi Giorgio, I think what's happening is that you are sending the keys "Cmd + S" or "Ctrl + S" to your code editor (thus triggering the saving of your code and the hot reload) while you need to send them towards the browser instead. You can use "Alt-tab" or "Cmd + tab" to alternate between open windows or just click on your browser and then type the keys. Let me know if it helped. Cheers from Belgium, |
Hi Raphael, I have the same issue — pressing Cmd + S / Ctrl + S:
Not sure it's related to "sending the keys to your code editor" — I don't see my editor uses these combinations to trigger anything related to re-run/refresh. [email protected] I'd appreciate if you can advise a solution. Kind regards, UPDATE |
hi everyone, same issue - Has anyone found a solution to fix it? Thank you |
This is a great hint! the Cmd-s / Ctrl-s should be pressed ON the browser, not in the editor |
When I press it on the browser it just causes it to iterate and saves an image that is not the one before the saving and not the one after it either. This behavior happens no matter where I press it, browser, editor or otherwise. |
@MrAmii You're right about this. This is because it rerenders the sketch to save it. Since you're getting different results each time, I'm assuming that you're using random numbers in your sketch. You can get consistent outputs in your save if you use a pseudorandom number generator and set the seed as the first thing you do in your sketch. This will effectively reset the seed when it is re-rendered in the save operation. Example boilerplate: const canvasSketch = require('canvas-sketch');
const { setSeed, value } = require('canvas-sketch-util/random');
const settings = {...};
const seed = Math.random();
// you can log your seed out which can be helpful to
// copy/paste into your code and use for debugging
console.log('seed: ' seed);
canvasSketch(({ update }) => {
return ({ context }) => {
setSeed(seed);
// use `value()` and other utils instead of `Math.random()`
const randomNumber = value();
//... sketch code ...
});
}, settings); |
@sfrieson Thank you for that breakdown, I have a much better understanding thanks to you. I have attempted to implement this in my very simple script made by following along with a course, but I have not been able to implement the last part where you call canvasSketch. You've already been a great help but would you mind taking a look at this script? I left the last part as it was. It is functioning currently with the most of what you described.
|
Hi @MrAmii try using Currently your code is producing “non deterministic” randomness when rendering which means it’s truly random each time it draws a frame. What you want is “deterministic” or “seeded” random, which is based on your seed that you set up. Since you’ve already set a seed, you can use the |
Hi everybody, I am trying for the first time canvas-sketch, but I am facing a problem.
Pressing cmd + S or ctrl + S an image should be saved, but the only thing that I get is a re-run of the code and nothing get saved.
I installed everything via npm, and these are my versions:
"canvas-sketch": "^0.7.6",
"canvas-sketch-cli": "^1.11.20"
I tried to export images in Chrome, Safari and Firefox, but I always get the same result.
Thank you in advance
Giorgio
The text was updated successfully, but these errors were encountered: