These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:21 pm Advanced search

Canvas to Canvas Copy Fail

Here you can discuss things related to HTML and the Web in general that do not fit in to other categories.

Canvas to Canvas Copy Fail

Postby Ed » Mon Sep 15, 2008 6:51 pm

I'm trying to copy from one canvas to another and i get:

uncaught exception: The type of an object is incompatible with the expected type of the parameter associated to the object (NS_ERROR_DOM_TYPE_M

I have 2 canvas dom objects and my code is:

var ctx = document.getElementById('canvas').getContext('2d');
var gtx = document.getElementById('gridbox').getContext('2d');

ctx.drawImage( gtx, 0, 0 );

both canvases are 500x400. The second canvas gtx has a grid of lines i've draw. I can see the grid drawn next to the main canvas, but it won't load it. I'm testing on FF3.

Anyone have any ideas/suggestions?
Ed
<h6>
 
Posts: 2
Joined: Mon Sep 15, 2008 6:41 pm

Postby Ed » Mon Sep 15, 2008 7:29 pm

Fixed. I was passing it the context of the second canvas and not just the dom object itself.

WOrking:

var ctx = document.getElementById('canvas').getContext('2d');
var gb = document.getElementById('gridbox');

ctx.drawImage( gb, 0, 0 );
Ed
<h6>
 
Posts: 2
Joined: Mon Sep 15, 2008 6:41 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest