javascript - Rotate and image canvas by user defined angle -
i want rotate image user defined angle determined input slider ranges -90deg 90deg. requirement straighten image on canvas. this have tried using angularjs my input slider , html : straighten: <input type="range" id="rotateimage" value="0" min="-90" max="90" step="1" ng-model="rotateangle"/> <div id="imagecanvas"> <canvas id="canvas"></canvas> </div> my controller: $scope.$watch('rotateangle', function(newval, oldval) { if (newval) { rotate(newval) } }) function rotate(rotangle) { console.log('rotate angle>> ', rotangle); var imagecanvas = document.getelementbyid("canvas"), context = canvas.getcontext("2d"); var gridwidth = imagecanvas.width, gridheight = imagecanvas.height; var deg = math.pi / 180; context.translate(gridwidth / 2, gridheight / 2); context.rotate(rotangle * deg); } also drawin