Reputation: 3046
im tryin to use this simple function: http://code.google.com/p/canvasimagegradient/ i have to create a linear transparent gradient with canvas and js (my image must be dynamic) but my code it's not working.. can you tell me where im wrong?
var ctx = $('#thecanvas')[0].getContext("2d");
var theImage= $('#theimage');
var linearGradient = ctx.createLinearGradient(0, 0, 0, theImage.height);
linearGradient.addColorStop(0, "transparent");
linearGradient.addColorStop(1, "#000");
ctx.drawImageGradient(theImage, 12, 65, linearGradient);
the debugger just says me: the console says me:
NOT_SUPPORTED_ERR: DOM Exception 9: The implementation did not support
just under this row:
var linearGradient = ctx.createLinearGradient(0, 0, 0, theImage.height);
thanks a lot in advance :)
Upvotes: 0
Views: 2085
Reputation: 14534
Is it because you are getting the image as a jQuery object, where height is a function, not a property? so you should have theImage.height()
, not theImage.height
?
Upvotes: 3