Replies: 2 comments 4 replies
-
I think this explains the problem. I met this problem before when experimenting with canvas and my solution was to, as the stackoverflow post has advised, set the loaded image's So, my advice would be to download a copy of the sketchpad plugin code and make some modifications yourself. Locate this part of code: add_background_image() {
return new Promise((resolve, reject) => {
if (this.params.background_image !== null) {
this.background_image = new Image();
this.background_image.src = this.params.background_image;
this.background_image.onload = () => {
this.ctx.drawImage(this.background_image, 0, 0);
resolve(true);
};
}
else {
resolve(false);
}
});
} Add after line 427, which is: this.background_image.src = this.params.background_image; Add this line of code: this.background_image.crossOrigin = 'Anonymous'; You will also need to make changes to how you import the sketchpad plugin. |
Beta Was this translation helpful? Give feedback.
-
Thank you, these code changes work! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
when using the jsPsychSketchpad function with a background image and saving a trial firefox gives this error:
"Uncaught DOMException: The operation is insecure."
This only happens when the "save_final_image" parameter is set to true, so somehow saving the png image seems to cause a problem.
EDIT: Using the Brave browser, I get a different error: "execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported."
The background I am using is in the same folder as the experiment and I am accessing it with a relative path.
How can I save the trial with a background enabled?
Beta Was this translation helpful? Give feedback.
All reactions