js canvas实现写字动画效果实现写字动画效果
主要为大家详细介绍了js canvas实现写字动画效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了js canvas实现写字动画效果展示的具体代码,供大家参考,具体内容如下
页面html:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>学写一个字</title>
<script src="jquery-2.1.3.min.js" type="text/javascript"></script>
<link href="handwriting.css" rel="stylesheet" type="text/css"/>
<meta name="viewport"
content=" height = device-height,
width = device-width,
initial-scale = 1.0,
minimum-scale = 1.0,
maximum-scale = 1.0,
user-scalable = no"/> //兼容移动端
</head>
<body>
<canvas id="canvas">
您的浏览器不支持canvas
</canvas>//写字区域
<div id="controller">
<div id="black_btn" class="color_btn color_btn_selected"></div>
<div id="blue_btn" class="color_btn"></div>
<div id="green_btn" class="color_btn"></div>
<div id="red_btn" class="color_btn"></div>
<div id="orange_btn" class="color_btn"></div>
<div id="yellow_btn" class="color_btn"></div>
<div id="clear_btn" class="op_btn">清 除</div>
<div class="clearfix"></div>
</div>
<script src = "handwriting.js"></script>
</body>
</html>
页面css:
#canvas{
display:block;
margin:0 auto;
}
#controller{
margin:0 auto;
}
.op_btn{
float: right;
margin:10px 0 0 10px;
border:2px solid #aaa;
width:80px;
height:40px;
line-height:40px;
font-size:20px;
text-align:center;
border-radius: 5px 5px;
cursor:pointer;
background-color: white;
font-weight:bold;
font-family: Microsoft Yahei, Arial;
}
.op_btn:hover{
background-color:#def;
}
.clearfix{
clear:both;
}
.color_btn{
float: left;
margin: 10px 10px 0 0;
border:5px solid white;
width:40px;
height:40px;
border-radius: 5px 5px;