还是前端图片的老话题,花了半天时间,东拼西凑,凑出个demo,优点在于代码少,核心代码就6行,目前刚做了旋转,缩放,裁剪,滤镜要js做,网络上也有现成的代码,

但是想做到自定义的滤镜咋办呢?这还要从底层了解滤镜的实现才行~实际上,我们无论用C++,还是java实现了滤镜,都能移植到js端,原理是相通的。

总之,再次强调,原理很重要,掌握了原理,你就可以任性了。

可以放到http://runjs.cn/里做验证,好棒的在线工具~

<!DOCTYPE html>
<html>
  <head>
 <meta charset="utf-8" />
 <title>js+css3</title>
  </head>
 <style type="text/css">
  .clipzone
  {
   position:relative;
   width:400px;
   height:400px;
   overflow:hidden;
  }
  .clipped
  {
   position:absolute;
  }
 </style>
  <body>
  <input type="button" value="rotate" onclick="rotate(20);"/>
  <input type="button" value="scale" onclick="scale(1.5);"/>
  <input type="button" value="clip" onclick="clip();"/>
  <input type="button" value="support_canvas_test" onclick="support_canvas_test();"/>
    <div class="clipzone" );  
  }
  var support_css3 = (function() {
   var div = document.createElement('div'),
    vendors = 'ms o moz webkit'.split(' '),
    len = vendors.length;
    
  return function(prop) { 
   if ( prop in div.style ) return true; 
   len = vendors.length;
   while(len--) {
     if ( vendors[len] + prop in div.style ) {
     return true; 
     } 
   } 
   return false;
     }; 
 })();
 
    </script>
  </body>
</html>

相关文章:

  • 2021-08-22
  • 2022-12-23
  • 2021-04-29
  • 2021-11-15
  • 2022-12-23
  • 2021-04-21
猜你喜欢
  • 2022-12-23
  • 2021-05-28
  • 2022-03-02
  • 2022-12-23
  • 2021-07-12
  • 2021-12-21
相关资源
相似解决方案