1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Bezier Animation</title>
<script src="../dist/zrender.js"></script>
<style>
body {
margin: 0;
}
#main {
border: 1px solid #ccc;
}
#rect {
position: absolute;
z-index: 10;
width: 100px;
height: 100px;
border: 1px solid #f00;
}
</style>
</head>
<body>
<div id="rect">100x100</div>
<div id="main" style="width:800px;height:400px;"></div>
<script type="text/javascript">
var canvas = document.createElement('canvas')
canvas.width = 400;
canvas.height = 400;
var ctx = canvas.getContext('2d');
var image = new Image();
image.onload = function() {
ctx.drawImage(image, 0, 0);
var zr = zrender.init(document.getElementById('main'));
var rect = new zrender.Rect({
shape: {
x: 0,
y: 0,
width: 200,
height: 200
},
style: {
fill: {
image: canvas,
rotation: Math.PI / 6,
scaleX: 0.5,
x: 100
}
}
});
zr.add(rect);
zr.setBackgroundColor({
image: image,
repeat: 'no-repeat'
});
};
image.src = './asset/test.png';
</script>
</body>
</html>
|