首页 >

js实现的页面矩阵图形变换特效【javascript】

web前端|js教程js实现的页面矩阵图形变换特效【javascript】
js,页面矩阵,图形变换,特效
web前端-js教程
软件开发公司源码,ubuntu配置命令大全,在哪看tomcat的端口号,集群爬虫是什么,php超市收银系统开源源码,青浦seo排名lzw
运行效果截图如下:
php 漂亮网站源码,ubuntu重启共享桌面,tomcat6服务器,python爬虫啥意思,php解压缩字符串,seo内容规则lzw
具体代码如下:
asp.net erp源码下载,vscode生态,ubuntu系统进程,验证tomcat,sqlite spy使用,网站服务器年线太长,jquery城市地区选择插件,layui前端框架详解,小象学院 爬虫,php转int,seo王光卫,dede网站限制IP浏览,鼠标双击关闭网页,网页文字模板,app充值页面模板,php物流后台管理系统模板,龙少泛站群程序论坛版lzw
          matrix          body {        margin:0; padding:0;background:black;      }      .rect {        background:green;       }      .arc {        border-radius:5px; background:green; box-shadow:2px solid #fff;      }      ul {        list-style:none; margin:0; padding:0; position:absolute;      }      li {        width:20px; height:20px; position:absolute;       }      h1 {        text-align:center; line-height:150px; font-size:150px; color:green;      }            

Chrome下兼容

var body = document.getElementsByTagName("body")[0]; function getColor() { var color = "rgb("; color += (10+Math.round(Math.random()*245)); color += ","; color += (10+Math.round(Math.random()*245)); color += ","; color += (10+Math.round(Math.random()*245)); color += ")"; return color; } var matrixData = [ [1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1] ]; var matrixData2 = [ [0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0],//1 [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],//2 [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],//3 [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],//4 [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],//5 [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],//6 [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],//7 [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0],//8 [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],//9 [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],//9 [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],//10 [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],//11 [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],//12 [0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0] //13 ]; function createDom(attrs) { var dom = document.createElement(attrs.tagName); attrs.style ? dom.setAttribute("style", attrs.style) : void(0); attrs.on ? dom.setAttribute("data-on", attrs.on) : void(0); return dom; } var ulList = []; var width = window.innerWidth; var height = window.innerHeight; var cols = Math.floor(width/120); var rows = Math.floor(height/120); var xOffset = Math.floor((width%120)/2); function createFlyer(attrs) { var iLength = matrixData.length, jLength = matrixData[0].length, radius = 20, ul = null, bgColor = getColor(); ul = createDom({tagName: "ul", style: "height:"+iLength*radius+"px; width:"+jLength*radius+"px; left:"+attrs.left+"px; top:"+attrs.top+"px"}); document.body.appendChild(ul); for(var i=0; i<5; i++) { var _data = matrixData[i]; for(var j=0; j<5; j++) { var style = "width:"+radius+"px; height:"+radius+"px;left:"+j*radius+"px; top:"+i*radius+"px;background:"+(_data[j] == 0 ? "transparent": bgColor); var li = createDom({tagName: "li", style: style, on: _data[j] ? 1 : 0}); ul.appendChild(li); } } ulList.push(ul); } for(var i=0; i<cols; i++) { for(var j=0; j<rows; j++) { createFlyer({left: i*120+xOffset, top: 120*j}); } } function setULBgColor(dom, color) { var lis = dom.getElementsByTagName("li"); for(var i=0,length=lis.length; i<length; i++) { var _li = lis[i]; console.log(_li.getAttribute("data-on")); _li.getAttribute("data-on") ? _li.style.backgroundColor = color : void(0); } } function reset(fn) { var lastIndex = ulList.length - 1; for(var i=0,length=ulList.length; i<length; i++) { var ul = ulList[i]; (function(i, ul) { setTimeout(function() { setULBgColor(ul, getColor()); if(i === lastIndex) { fn ? fn() : void(0); } }, i*30); })(i, ul); } }; function firstStep() { var color = getColor(); var lastIndex = ulList.length - 1; for(var i=0,length=ulList.length; i 720) { angle = 0; clearInterval(interval); createMatrix2(); } for(var i=0,length=ulList.length; i<length; i++) { var ul = ulList[i]; ul.style.webkitTransform = "rotate("+angle+"deg)"; } }, 50); } function createMatrix2() { body.innerHTML = ""; var iLength = matrixData2.length, jLength = matrixData2[0].length, radius = 20, ul = null, height = jLength*radius, width = iLength*radius, bgColor = getColor(), left = (window.innerWidth - width)/2, top = (window.innerHeight - height)/2 console.log(window.innerWidth); console.log(width); ul = createDom({tagName: "ul", style: "height:"+iLength*radius+"px; width:"+jLength*radius+"px; left:"+left+"px; top:"+top+"px"}); document.body.appendChild(ul); for(var i=0; i<iLength; i++) { var _data = matrixData2[i]; for(var j=0; j 1) { clearInterval(interval); } }, 50); } firstStep();
更多关于js特效相关内容感兴趣的读者可查看本站专题:《jQuery动画与特效用法总结》及《jQuery常见经典特效汇总》


  • 暂无相关文章