Difference between revisions of "Template:Pitt"
Line 77: | Line 77: | ||
}); | }); | ||
var c = document.getElementById("bannerCanvas"); | var c = document.getElementById("bannerCanvas"); | ||
− | c.height = $( | + | c.height = $(window).height(); |
− | c.width = $( | + | c.width = $(window).width(); |
var ctx = c.getContext('2d'); | var ctx = c.getContext('2d'); | ||
ctx.fillRect(0, 0, c.width, c.height); | ctx.fillRect(0, 0, c.width, c.height); | ||
Line 249: | Line 249: | ||
var c = document.getElementById("bannerCanvas"); | var c = document.getElementById("bannerCanvas"); | ||
− | c.height = $( | + | c.height = $(window).height(); |
− | c.width = $( | + | c.width = $(window).width(); |
var ctx = c.getContext('2d'); | var ctx = c.getContext('2d'); | ||
− | |||
ctx.fillRect(0, 0, c.width, c.height); | ctx.fillRect(0, 0, c.width, c.height); | ||
+ | |||
+ | var circles = []; | ||
$("#bannerContainer").mousemove(function(event){ | $("#bannerContainer").mousemove(function(event){ | ||
+ | circles.push(event.clientX); | ||
+ | circles.push(event.clientY); | ||
+ | circles.push(400); | ||
+ | }); | ||
+ | |||
+ | function render(){ | ||
var c = document.getElementById("bannerCanvas"); | var c = document.getElementById("bannerCanvas"); | ||
var ctx = c.getContext('2d'); | var ctx = c.getContext('2d'); | ||
+ | ctx.fillRect(0, 0, c.width, c.height); | ||
var iD= ctx.getImageData(0, 0, c.width, c.height); | var iD= ctx.getImageData(0, 0, c.width, c.height); | ||
var data = iD.data; | var data = iD.data; | ||
− | var | + | var color; |
− | + | ||
− | for(y = 0; y < c.height; y++) { | + | for(var z = 0; z < circles.length; z += 3){ |
− | + | for(var y = Math.max(0, circles[z + 1] - 10); y < Math.min(c.height, circles[z + 1] + 10); y++){ | |
− | + | for(var x = Math.max(0, circles[z] - 10); x < Math.min(c.width, circles[z] + 10); x++){ | |
− | + | color = 1 / 5 / c.width * Math.max(0, 5 * c.width - (x - circles[z]) * (x - circles[z]) - (y - circles[z+1]) * (y - circles[z+1])); | |
− | + | data[((c.width * y) + x) * 4] = Math.max(data[((c.width * y) + x) * 4], circles[z+2] * color); | |
− | + | data[((c.width * y) + x) * 4 + 1] = Math.max(data[((c.width * y) + x) * 4 + 1], circles[z+2] * color); | |
+ | data[((c.width * y) + x) * 4 + 2] = Math.max(data[((c.width * y) + x) * 4 + 2], circles[z+2] * color); | ||
+ | } | ||
+ | } | ||
+ | circles[z+2] -= 3; | ||
+ | if(circles[z+2] < 0){ | ||
+ | circles.splice(z, 3); | ||
+ | z -= 3; | ||
} | } | ||
} | } | ||
ctx.putImageData(iD, 0, 0); | ctx.putImageData(iD, 0, 0); | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | setInterval( | + | setInterval(render, 25); |
}); | }); | ||
Line 449: | Line 455: | ||
#bannerCanvas { | #bannerCanvas { | ||
− | position: | + | position: fixed; |
width: 100%; | width: 100%; | ||
z-index:-1; | z-index:-1; |
Revision as of 16:24, 5 June 2015