I'm trying to rotate an image on canvas when the image is loaded, but it's not showing up and I get no javascript errors.
here's the code:
function drawImage(pictureId, direction, ctx, posX, posY) {
var image = document.createElement("img");
//i set the image src here
image.onload = function () {
drawRotated(image, direction, posX, posY);
}
}
function drawRotated(image, direction, posX, posY) {
ctx.save();
ctx.rotate((direction*90)*(Math.PI/180));
ctx.drawImage(image, posX, posY);
ctx.restore();
}