JSFiddle - React, Tailwind, and code Playground
HTML
<img src="http://jsfiddle.net/img/logo.png" width="160" height="25" />
<canvas id="canv" width="500" height="500"></canvas>
JavaScript
$(function() {
var img = new Image();
var canvas = $('#canv')[0];
var context = canvas.getContext('2d');
img.onload = function() {
// if you comment this line, it works
context.rotate(0.5 * Math.PI);
context.drawImage(img, 0, 0, 160, 25);
};
img.src = "http://jsfiddle.net/img/logo.png";
});