We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm running 05.js 0.4.6 and am attempting the save() function to download a image from the canvas and am getting the error:
Uncaught TypeError: Cannot read property 'toDataURL' of undefined
Example of JS (not my actual javascript being used):
function setup() {
//Creating the webpage interface
var canvas = createCanvas(1280, 1280);
canvas.parent('container');
canvas.position(0,0);
textSize(14);
//Variable center of screen
centerx = width/2;
centery = height/2;
//Creating the # of authors input (will be replced with CSV data)
but = createInput("10");
but.position((200-176)/2,10);
save('test.png');
}
This is being drawn within the HTML. Running this just leads to that error. What should I do to fix? Thanks!
Answers
I was able to make it run it w/o error by moving save() into draw().
And also by explicitly passing the canvas' reference to it:
Although I still think it's very buggy and should be reported here:
https://GitHub.com/processing/p5.js/issues
Don't forget to mention your thread here there! O:-)