Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var stage = new Konva.Stage({
- container: 'dibujo',
- width: 556,
- height: 316
- });
- function crearAnimacion(star){
- var anim = new Konva.Animation(function(frame) {
- var scale = Math.sin(frame.time * 2.5 * Math.PI / 2000) + 0.001;
- star.scale({ x :scale, y : scale});
- var angleDiff = frame.timeDiff * 90/ 1000;
- star.rotate(angleDiff);
- }, layer);
- anim.start();
- }
- function crearEstrella(){
- var sX, sY;
- sX = sY = Math.random();
- return new Konva.Star({
- x: Math.floor(Math.random() * 556),
- y: Math.floor(Math.random() * 316),
- numPoints: 5,
- innerRadius: 40,
- outerRadius: 80,
- rotation: Math.floor(Math.random() * 360),
- scaleX: sX,
- scaleY: sY,
- fill: 'yellow',
- stroke: 'black',
- strokeWidth: 1,
- opacity: 0.8,
- draggable: true
- });
- }
- var layer = new Konva.Layer();
- for(var i = 1; i <= 5; ++i){
- var star = crearEstrella();
- layer.add(star);
- crearAnimacion(star);
- }
- stage.add(layer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement