svg滤镜实现特效
代码语言:html
所属分类:视觉差异
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title> SVG-filter on canvas 4</title> <style> * { margin: 0; } .wrapper { width: 100%; height: 100%; } body { background-color: #222222; } canvas#myCanvas { filter: url(#filter); display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; } </style> </head> <body translate="no"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" /> <script src="https://code.createjs.com/1.0.0/createjs.min.js"></script> <div class="wrapper"> <div class="canvas"> <canvas id="myCanvas" width="640" height="640"></canvas> </div> </div> <svg version="1.1" xmlns='http://www.w3.org/2000/svg'> <defs> <filter id='filter'> <feGaussianBlur id="feGaussianBlur" stdDeviation='10' /> <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7" result="joint" /> <feTurbulence id="feTurbulence" type="turbulence" baseFrequency="0.05" numOctaves="1" result="turbulence" /> <feDisplacementMap id="feDisplacementMap" in2="turbulence" in="SourceGraphic" scale="100" xChannelSelector="R" yChannelSelector="G" /> </filter> </defs> </svg> <script> window.addEventListener('load', init); window.addEventListener('load', handleResize); //ロード時リサイズをかける var stage; var angle = 0; var particles; var objectPool = []; // オブジェクトプール function init() { stage = new createjs.Stage('myCanvas'); window.addEventListener("resize", function() { handleResize(); }); var particles = new Particle(40, "#FFF", 20, 20, 50, 0.99)//(size,color,vx,vy,life, gravity) stage.addChild(particles); createjs.Ticker.addEventListener("tick", handleTick); createjs.Ticker.timingMode = createjs.Ticker.RAF; function handleTick(event) { stage.update(); } } class Particle extends createjs.Container { constructor(size, color, .........完整代码请登录后点击上方下载按钮下载查看
网友评论0