Animation in Kinetic.js

<html>
<body>
<div id=”ok”></div>
<script src=”http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v5.0.0.min.js”></script&gt;
<script defer=”defer”>
var stage=new Kinetic.Stage({
container:’ok’,
width:500,
height:500
});
var layer=new Kinetic.Layer();
var haxagon=new Kinetic.RegularPolygon({
x:stage.width()/2,
y:stage.height()/2,
sides:6,
radius:70,
fill:’red’,
stroke:’black’,
strokeWidth:4
});
layer.add(haxagon);
stage.add(layer);
var am=150;
var per=2000;
var cent=stage.width()/2;

var ani=new Kinetic.Animation(function(frame){
haxagon.setX(am*Math.sin(frame.time*2*Math.PI/per)+cent);
},layer);
ani.start();
</script>
</body>
</html>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s