kineticjs image

by bighostkim

HTML

<div id="container">
</div>
<script>
var stage = new Kinetic.Stage({
    container: "container",
    width: 600,
    height: 300
});
var layer = new Kinetic.Layer();

var imageObj = new Image();
imageObj.src = "http://www.html5canvastutorials.com/demos/assets/yoda.jpg";
imageObj.onload = function () { layer.draw();};

var image = new Kinetic.Image({
    image: imageObj,
    x: stage.getWidth() / 2 ,
    y: stage.getHeight() / 2,
    width: imageObj.width,
    height: imageObj.height,
    offset: [imageObj.width/2, imageObj.height/2]
});

layer.add(image);
stage.add(layer);
</script>