原生JS做一个画板

  • 预览链接 https://erdoszrf.github.io/Painter/index.html
  • 代码链接 https://github.com/Erdoszrf/Painter

知识点

鼠标的事件
  • onmousedown()鼠标按下
  • onmousemove()鼠标移动
  • onmouseup()鼠标弹起
触屏设备事件
  • ontouchstart触碰
  • ontouchmove触摸并移动
  • ontouchend不触碰
制作思路
  1. 画一个canvas出来
  2. 定义监听函数,在函数内定义鼠标以及触屏事件,实现可以划线
  3. 在阿里矢量图库寻找适合图标,放入画布
  4. 为对应图标添加onclick事件,点击后加入对应class名字

你可能感兴趣的:(原生JS做一个画板)