大家可以自行配个mp3更带感:
<audio src="mp3地址" autoplay></audio>
预览:
全屏预览,带音乐(退出刷新页面即可):
用法:
//直接用,填满窗口
dancerRobot();
//在canvas对象里,需要定义canvas对象
dancerRobot('#dancerRobot');
//机器人的大小,仅两种:大和小,小true,大false
dancerRobot(false,true);示例(直接用):<!doctype html> <html> <head> <meta charset="utf-8"> <title>跳舞的机器人</title> </head> <body> <script src="http://cdn.hadsky.com/js/other/dancerRobot.min.js"></script> <script> window.onload = dancerRobot(); </script> </body> </html>示例(指定用):
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>跳舞的机器人</title>
<style>
body,
html {
position: absolute;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden
}
#dancerRobot {
position: absolute;
width: 100%;
height: 100%;
background: #ccc;
cursor: pointer
}
</style>
</head>
<body>
<canvas id="dancerRobot"></canvas>
<script src="http://cdn.hadsky.com/js/other/dancerRobot.min.js"></script>
<script>
window.onload = dancerRobot("#dancerRobot");
</script>
</body>
</html>