a simple image clipper.
image clipper, headshot editor 图片裁剪工具, 头像编辑器
let myCliper = new Clipper(container [, options])
<!-- SET A CONTAINER 设置一个容器 -->
<div id="clipper-container"></div>
<!-- include 引入 -->
<script src="Clipper.js"></script>
<!-- initialize 初始化 -->
<script>
let container = document.getElementById('clipper-container')
// init without options
let clipper = new Clipper(container)
</script>
let clipper = new Clipper(container, {
coverShape: 'circle',
coverColor: '#000000',
coverSize: 0.8,
coverOpacity: 0.8
})
coverShape
coverColor
coverSize
coverOpacity
let clipper = new Clipper(container)
clipper.drawImg(url)
note: it is never output a circle image,we can display with CSS border-radius 注意: 不会输出圆形的图片,我们可以在显示的时候使用CSS的圆角属性
let clipper = new Clipper(container)
clipper.drawImg(url)
//clipper.clip([cb] [,options])
clipper.clip()
data: base64 or blob,accord to options.format 根据options.format变化
mouse OR touch 鼠标或触摸: press and move 按住移动
extend 扩展:
let clipper = new Clipper(container)
clipper.drawImg(url)
//read (x,y) 获取坐标 :
let x = cliper.imgX
let y = cliper.imgY
// set (sx,sy) 设置坐标
clipper.imgNextX = sx
clipper.imgNextY = sy
mouse 鼠标: with wheel 使用滚轮
touch 触摸: with gesture 使用手势
extend 扩展:
let clipper = new Clipper(container)
clipper.drawImg(url)
//read scale 获取缩放比例 :
let scale = clipper.imgScale
// set scale 设置股缩放比例
clipper.imgNextScale = scale
mouse 鼠标 no set 没有设置
touch 触摸: with gesture 使用手势
extend 扩展:
let clipper = new Clipper(container)
clipper.drawImg(url)
//read rotate 获取缩放比例 :
let rotate = clipper.rotate
// set rotate 设置缩放比例
clipper.nextRotate = rotate