1var refreshDuration = 10000; 2var refreshTimeout; 3var numPointsX; 4var numPointsY; 5var unitWidth; 6var unitHeight; 7var points; 8 9function onLoad() 10{ 11 var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); 12 svg.setAttribute('width',window.innerWidth); 13 svg.setAttribute('height',600); 14 document.querySelector('#bg').appendChild(svg); 15 16 var unitSize = (window.innerWidth+600)/20; 17 numPointsX = Math.ceil(window.innerWidth/unitSize)+1; 18 numPointsY = Math.ceil(600/unitSize)+1; 19 unitWidth = Math.ceil(window.innerWidth/(numPointsX-1)); 20 unitHeight = Math.ceil(600/(numPointsY-1)); 21 22 points = []; 23 24 for(var y = 0; y < numPointsY; y++) { 25 for(var x = 0; x < numPointsX; x++) { 26 points.push({x:unitWidth*x, y:unitHeight*y, originX:unitWidth*x, originY:unitHeight*y}); 27 } 28 } 29 30 randomize(); 31 32 for(var i = 0; i < points.length; i++) { 33 if(points[i].originX != unitWidth*(numPointsX-1) && points[i].originY != unitHeight*(numPointsY-1)) { 34 var topLeftX = points[i].x; 35 var topLeftY = points[i].y; 36 var topRightX = points[i+1].x; 37 var topRightY = points[i+1].y; 38 var bottomLeftX = points[i+numPointsX].x; 39 var bottomLeftY = points[i+numPointsX].y; 40 var bottomRightX = points[i+numPointsX+1].x; 41 var bottomRightY = points[i+numPointsX+1].y; 42 43 var rando = Math.floor(Math.random()*2); 44 45 for(var n = 0; n < 2; n++) { 46 var polygon = document.createElementNS(svg.namespaceURI, 'polygon'); 47 48 if(rando==0) { 49 if(n==0) { 50 polygon.point1 = i; 51 polygon.point2 = i+numPointsX; 52 polygon.point3 = i+numPointsX+1; 53 polygon.setAttribute('points',topLeftX+','+topLeftY+' '+bottomLeftX+','+bottomLeftY+' '+bottomRightX+','+bottomRightY); 54 } else if(n==1) { 55 polygon.point1 = i; 56 polygon.point2 = i+1; 57 polygon.point3 = i+numPointsX+1; 58 polygon.setAttribute('points',topLeftX+','+topLeftY+' '+topRightX+','+topRightY+' '+bottomRightX+','+bottomRightY); 59 } 60 } else if(rando==1) { 61 if(n==0) { 62 polygon.point1 = i; 63 polygon.point2 = i+numPointsX; 64 polygon.point3 = i+1; 65 polygon.setAttribute('points',topLeftX+','+topLeftY+' '+bottomLeftX+','+bottomLeftY+' '+topRightX+','+topRightY); 66 } else if(n==1) { 67 polygon.point1 = i+numPointsX; 68 polygon.point2 = i+1; 69 polygon.point3 = i+numPointsX+1; 70 polygon.setAttribute('points',bottomLeftX+','+bottomLeftY+' '+topRightX+','+topRightY+' '+bottomRightX+','+bottomRightY); 71 } 72 } 73 polygon.setAttribute('fill','rgba(0,0,0,'+(Math.random()/3)+')'); 74 svg.appendChild(polygon); 75 } 76 } 77 } 78} 79 80function randomize() { 81 for(var i = 0; i < points.length; i++) { 82 if(points[i].originX != 0 && points[i].originX != unitWidth*(numPointsX-1)) { 83 points[i].x = points[i].originX + Math.random()*unitWidth-unitWidth/2; 84 } 85 if(points[i].originY != 0 && points[i].originY != unitHeight*(numPointsY-1)) { 86 points[i].y = points[i].originY + Math.random()*unitHeight-unitHeight/2; 87 } 88 } 89} 90 91function onResize() { 92 document.querySelector('#bg svg').remove(); 93 onLoad(); 94} 95 96window.onload = onLoad; 97window.onresize = onResize;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.