<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div id="box"></div>
</body>
<script src="./bower_components/konva/konva.js"></script>
<script>
var stage=new Konva.Stage({
container:"box",
width:window.innerWidth,
height:window.innerHeight,
})
var layer=new Konva.Layer();
stage.add(layer);
var rect=new Konva.Rect({
x:200,
y:200,
width:200,
height:200,
offset:{
x:100,
y:100
},
stroke:"red",
fill:"pink",
strokeWidth:10,
cornerRadius:5,
draggable:true,//是否进行拖拽
})
layer.add(rect);
var animation=new Konva.Animation(function(){
rect.rotate(10);
},layer);
animation.start();
layer.draw();
</script>
</html>
1.png
网友评论