Coder Social home page Coder Social logo

graffitijs's Introduction

GraffitiJs

基于javascript ES6版本编写的涂鸦和擦除功能,支持pc和移动端

demo:https://002301.github.io/GraffitiJs/src/

安装

npm i @airmn/graffiti

使用方法

npm

<script type="module">
import GraffitiJs from "@airmn/graffiti"

let drow = new GraffitiJs('.drow',{
    bg:"#253d39", 
    color: "#e3e3e3", 
    lineWidth: "10"
});
</script>

初始化参数

GraffitiJs(dom,config)

dom:class|id

config

  • bg : (color|URL)设置背景,可以是 rgba|#fff|imageUrl 图片地址
  • color:#fff 设置画笔颜色
  • lineWidth:30 设置画笔粗细
  • scratch:false 设置涂鸦还是擦除
  • percent:0.5 设置擦除百分比,达到后执行结束回调函数
  • onComplete:function 设置结束回调

例如:

//创建涂鸦板
let scratch = new GraffitiJs('.scratch',{
 color:"#e3e3e3",
 percent:0.5,
 scratch:true,
 bg:"./images/bg.jpg",
 onComplete:()=>{
   	console.log('scratch')
   }});

其他方法

重新设置画笔颜色 drow.setColor("#71717")

0.1.3 更新

修复滚动页面坐标偏移问题

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.