skoumas
skoumas

Reputation: 199

Canvas 'drawImage' returns ' No function was found that matched the signature provided.'

I have two HTML5 canvases. I draw first on a temp one and then I want to copy the temp to the final one. Everything seems to work except the drawImage function which is weird because it accepts Images as well Canvases. I tried already the convert to DatatoUrl() method with no success.

These are the objects I am using. Sizes etc are all set later.

var paint = $('<canvas/>');
var temp_paint = $('<canvas/>');
temp_ctx = temp_paint[0].getContext('2d');
ctx = paint[0].getContext('2d');

Any ideas?

This is the code

function paintMouseUp(e) 
{
    e.preventDefault();
    draw=false; 
    ctx.drawImage(temp_paint, 0, 0);
    temp_ctx.clearRect(0, 0, settings.width, settings.height);
    mousePoints = [];
}

This is the error I am getting:

Failed to execute 'drawImage' on 'CanvasRenderingContext2D': No function was found that matched the signature provided.

Upvotes: 2

Views: 4843

Answers (1)

Regent
Regent

Reputation: 5178

temp_paint is jQuery's object, so it can't be .drawImage() first argument. You can use this code instead:

ctx.drawImage(temp_ctx.canvas, 0, 0);

Fiddle example

Upvotes: 1

Related Questions