scrawl

功能描述

移动端canvas画板涂鸦绘图特效,用例见 scrawl.html

依赖的模块

  1. ./libs/css/handwriting.css
  2. ./libs/js/jquery.min.js
  3. ./libs/js/handwriting.js

快速使用

引入以上三个依赖文件

  1. <link rel="stylesheet" type="text/css" href="./libs/css/handwriting.css">
  2. <script type="application/javascript" src="./libs/js/jquery.min.js"></script>
  3. <script type="application/javascript" src="./libs/js/handwriting.js"></script>

页面画板dom

  1. <div class="wrapper">
  2. <canvas class="offCanvas"></canvas>
  3. <canvas class="canvas"></canvas>
  4. </div>

底部工具栏

  1. <div class="footer">
  2. <div class="control-button">
  3. <div class="item colorButton"><img src="./image/colors.png" alt=""><span>黑色</span></div>
  4. <div class="item sizeButton"><img src="./image/size.png" alt=""><span>中笔</span></div>
  5. <div class="item bgButton"><img src="./image/bg.png" alt=""><span>背景</span></div>
  6. <div class="item rubberButton"><img src="./image/rubber.png" alt=""><span>擦掉</span></div>
  7. <div class="item historyButton"><img src="./image/history.png" alt=""><span>历史</span></div>
  8. <div class="item clearButton"><img src="./image/clear.png" alt=""><span>清屏</span></div>
  9. <div class="item saveButton"><img src="./image/save.png" alt=""><span>保存</span></div>
  10. </div>
  11. <div class="pop-up colors-panel">
  12. <div class="title">笔触颜色<span class="closeBtn"></span></div>
  13. <div class="colors">
  14. <div class="lineColors">
  15. <div><span class="red" data-text="红色" data-color="#ff0000"></span></div>
  16. <div><span class="blue" data-text="蓝色" data-color="#0000ff"></span></div>
  17. <div><span class="green" data-text="绿色" data-color="#00ff00"></span></div>
  18. <div><span class="black" data-text="黑色" data-color="#000000"></span></div>
  19. <div><span class="orange" data-text="橙色" data-color="#ff6302"></span></div>
  20. </div>
  21. <div class="lineColors">
  22. <div><span class="red" data-text="红色" data-color="#ff0000"></span></div>
  23. <div><span class="blue" data-text="蓝色" data-color="#0000ff"></span></div>
  24. <div><span class="green" data-text="绿色" data-color="#00ff00"></span></div>
  25. <div><span class="black" data-text="黑色" data-color="#000000"></span></div>
  26. <div><span class="orange" data-text="橙色" data-color="#ff6302"></span></div>
  27. </div>
  28. </div>
  29. </div>
  30. <div class="pop-up size-panel">
  31. <div class="title">笔触大小<span class="closeBtn"></span></div>
  32. <div class="sizes">
  33. <div class="lineSizes"><span data-lineWidth="10" data-text="大笔" class="big"></span></div>
  34. <div class="lineSizes"><span data-lineWidth="30" data-text="中笔" class="middle"></span></div>
  35. <div class="lineSizes"><span data-lineWidth="50" data-text="小笔" class="small"></span></div>
  36. </div>
  37. </div>
  38. <div class="pop-up bg-panel">
  39. <div class="title">推荐背景<span class="closeBtn"></span></div>
  40. <div class="list">
  41. <img src="./image/bj.png" alt="" />
  42. <img src="./image/bj.png" alt="" />
  43. <img src="./image/bj.png" alt="" />
  44. <img src="./image/bj.png" alt="" />
  45. <img src="./image/bj.png" alt="" />
  46. </div>
  47. </div>
  48. <!-- 添加橡皮檫列表和历史记录列表样式 -->
  49. <div class="pop-up rubber-panel">
  50. <div class="title">橡皮檫大小<span class="closeBtn"></span></div>
  51. <div class="rubbers">
  52. <div class="first">大小:</div>
  53. <div class="second"><input type="range" min="1" max="50" value="25" step="1" name="大小" /></div>
  54. <div class="last"><span class="rubberSize">25</span>像素</div>
  55. </div>
  56. </div>
  57. <div class="pop-up history-panel">
  58. <div class="title">历史记录<span class="closeBtn"></span></div>
  59. <div class="history">
  60. <div class="lineBox"></div>
  61. </div>
  62. </div>
  63. </div>
  64. <div class="offImgs" style="display: none;"></div>