移动端canvas实现涂鸦效果插件

移动端canvas实现涂鸦效果插件

移动端canvas实现涂鸦效果插件,实现涂鸦基本功能、更改笔触大小颜色、更改背景图、橡皮檫、历史记录、清屏和保存功能。

使用方法
在页面引入相关CSS样式文件

1
2
<link rel="stylesheet" type="text/css" href="css/base.css">
<link rel="stylesheet" type="text/css" href="css/handWriting.css">

JS代码

1
2
<script type="text/javascript" src="js/jquery.min.js"></script>
<script src="js/handWriting.js"></script>

HTML结构代码

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
63
64
65
66
67
<div class="wrapper">
<canvas class="offCanvas"></canvas>
<canvas class="canvas"></canvas>
</div>
<div class="footer">
<div class="control-button">
<div class="item colorButton"><img src="images/colors.png" alt=""><span>黑色</span></div>
<div class="item sizeButton"><img src="images/size.png" alt=""><span>中笔</span></div>
<div class="item bgButton"><img src="images/bg.png" alt=""><span>背景</span></div>
<div class="item rubberButton"><img src="images/rubber.png" alt=""><span>擦掉</span></div>
<div class="item historyButton"><img src="images/history.png" alt=""><span>历史</span></div>
<div class="item clearButton"><img src="images/clear.png" alt=""><span>清屏</span></div>
<div class="item saveButton"><img src="images/save.png" alt=""><span>保存</span></div>
</div>
<div class="pop-up colors-panel">
<div class="title">笔触颜色<span class="closeBtn"></span></div>
<div class="colors">
<div class="lineColors">
<div><span class="red" data-text="红色" data-color="#ff0000"></span></div>
<div><span class="blue" data-text="蓝色" data-color="#0000ff"></span></div>
<div><span class="green" data-text="绿色" data-color="#00ff00"></span></div>
<div><span class="black" data-text="黑色" data-color="#000000"></span></div>
<div><span class="orange" data-text="橙色" data-color="#ff6302"></span></div>
</div>
<div class="lineColors">
<div><span class="red" data-text="红色" data-color="#ff0000"></span></div>
<div><span class="blue" data-text="蓝色" data-color="#0000ff"></span></div>
<div><span class="green" data-text="绿色" data-color="#00ff00"></span></div>
<div><span class="black" data-text="黑色" data-color="#000000"></span></div>
<div><span class="orange" data-text="橙色" data-color="#ff6302"></span></div>
</div>
</div>
</div>
<div class="pop-up size-panel">
<div class="title">笔触大小<span class="closeBtn"></span></div>
<div class="sizes">
<div class="lineSizes"><span data-lineWidth="10" data-text="大笔" class="big"></span></div>
<div class="lineSizes"><span data-lineWidth="30" data-text="中笔" class="middle"></span></div>
<div class="lineSizes"><span data-lineWidth="50" data-text="小笔" class="small"></span></div>
</div>
</div>
<div class="pop-up bg-panel">
<div class="title">推荐背景<span class="closeBtn"></span></div>
<div class="list">
<img src="images/bj.png" alt="" />
<img src="images/bj.png" alt="" />
<img src="images/bj.png" alt="" />
<img src="images/bj.png" alt="" />
<img src="images/bj.png" alt="" />
</div>
</div>

<div class="pop-up rubber-panel">
<div class="title">橡皮檫大小<span class="closeBtn"></span></div>
<div class="rubbers">
<div class="first">大小:</div>
 <div class="second"><input type="range" min="1" max="50" value="25" step="1" name="大小" /></div>
<div class="last"><span class="rubberSize">25</span>像素</div>
</div>
</div>
<div class="pop-up history-panel">
<div class="title">历史记录<span class="closeBtn"></span></div>
<div class="history">
<div class="lineBox"></div>
</div>
</div>
</div>
当前内容只有登录了才能查看,如果您已经注册,请登录
2

发表评论