裁切图片

xiaoxiao2021-02-28  153

案例地址1 :http://www.lcfbk.top/other/clip_img/1.html

案例地址2 :http://www.lcfbk.top/other/clip_img/2.html

 

使用方法 :

 

 var cb = new clipBitmap().init({     'ctx' : document.getElementById('ctx'), //存放canvas的容器     'mode' : 'O',   //  模式 O 或者 R     'img' : 'res/pic.jpg',  //背景图     'rimg' : 'res/timg.png' //定位图片,可忽略。忽略后将调用默认的定位图 }); $('#clip').on('click', function(){     if (cb != null) {         var img = cb.clipG();   //调用clipG()方法会返回base64数据的img         document.body.innerHTML = '';         document.body.appendChild(img)     } });

上面的modeO代表定位图片为圆形,R为矩形。 默认为矩形,此参数能省略。

 

rimg为定位的图片,省略的话则会根据mode是矩形或者圆形调用相应的图片  

 

 

 

转载请注明原文地址: https://www.6miu.com/read-26991.html

最新回复(0)