I came today to show an error caused by an operation in jQuery about converting an object, here is the code (function setColor (x, y)):
colourpixel = $('#colour').css('background-color').match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);//["rgb(0, 70, 255", "0", "70", "255"]
var canvas = document.createElement('canvas');
canvas.height=190;
canvas.width=190;
canvascontext = canvas.getContext("2d");
defaultdata = $('#light').get(0).getContext("2d").getImageData(0,0,190,190);
canvascontext.putImageData(defaultdata,0,0);
canvascontext.globalCompositeOperation = 'destination-atop';
canvascontext.fillStyle='rgb( '+colourpixel[1]+', '+colourpixel[2]+', '+colourpixel[3]+')';
And here is the error caused by opera:
Uncaught exception: TypeError: Cannot convert 'colourpixel' to object
Error thrown at line 157, column 1 in setColor(x, y) in file:
canvascontext.fillStyle='rgb( '+colourpixel[1]+', '+colourpixel[2]+', '+colourpixel[3]+')';
called from line 61, column 2 in <anonymous function>(event) in file:
setColor(x,y);
called from line 55, column 294 in <anonymous function: handle>(a) in file:
i=i.handler.apply(this,arguments);
called via Function.prototype.apply() from line 49, column 569 in <anonymous function: o>() in file:
return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w
I tried to create an object as an array (var colourpixel = new Array ();), but nothing starts.
Thank you in advance!
source
share