How to rotate image using HTML5 canvas library like: KineticJS or KonvaJS? -


i able rotate rectangle (shape) using kineticjs library rotate image, how can that?

var stage = new kinetic.stage({  	container: 'container',  	width: 530,  	height: 530  });  var layer = new kinetic.layer();    var bg = new kinetic.image({      x: 0,      y: 0,      width: 530,      height: 530,      fill: '#d7d7d7',  });  /****************** image **********************/  //sticker.setrotationdeg(90);  var imageobj = new image();  function sticker(v) {  	if(!imageobj.src){  		var sticker = new kinetic.image({  			x: 280,  			y: 300,  			image: imageobj,  			draggable: true  		});  		layer.add(sticker);  	}  	imageobj.src = 'http://cdn.sstatic.net/photo/img/apple-touch-icon.png';  	layer.draw();  }  /****************** image **********************/      layer.add(bg);  stage.add(layer);
<script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.4.2.min.js"></script>  <div id="container"></div>  <input type="button" value="showsticker" onclick="sticker();"> click show sticker  <input type="button" value="rotate"> + 5 

i want click rotation

step 1 click button show sticker

step 2 click button rotate

each time press + 5

or see web : http://jsfiddle.net/m1erickson/z6yg8/

as have understood you want rotate image, here following:

first suggest use konvajs library forked kineticjs supported community, keniticjs no longer supported.

in order rotate in image need load layer:

imageobj.onload = function() {    var yoda = new konva.image({     x: 50,     y: 50,     image: imageobj,     width: 106,     height: 118,     name: "yoda"   }); 

and rotate it:

$("#rotate").click(function () {      layer.find('image').rotate(500 * math.pi / 180);       layer.draw();   }); 

here full example


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -