/* context 上下文 color 颜色 width 线条宽度 interval 间隔 type 竖线还是横线 number 条数 length 长度 */ function lattice(context,color,width,interval,type,number,length){ var index = 0; var lst = window.setInterval(function(){ var x = 0; var y = 0; if(type) x=interval*index; else y=interval*index; var ernal = window.setInterval(function() { context.fillStyle = color; context.fillRect(x, y, width, width); var k = !type?++x:++y; console.info("x:"+x); if (k > length) { window.clearInterval(ernal); } },0); index++; if (index >= number) { window.clearInterval(lst); } },20); } lattice(context, "red", 1, 20, true, 51, 1000); lattice(context, "red", 1, 20, false, 51, 1000);
转载于:https://www.cnblogs.com/yinqi/archive/2013/01/15/2861738.html
相关资源:易语言画格子源码