1loadtree('/images/02/index/img-aboutBg.png'); 2 3function loadtree(imglink){ 4 var canvas = document.getElementById('treeCanvas') 5 var ctx = canvas.getContext('2d') 6 7 var img_max_width = 600 8 var img_max_height = 600 9 var imgWidth, imgHeight 10 11 var image = new Image() 12 image.src = imglink 13 14 var amplitude = 10 // éå¹ 15 var period = .5 // é±ææ¸ 16 var frequency = .3 // é »ç 17 var wavelength // æ³¢é· 18 var v // æ³¢é 19 var cftX // xä¿æ¸ 20 var cftA // éå¹ ä¿æ¸ 21 22 image.onload = function (ev){ 23 imgWidth = Math.floor(image.width) 24 imgHeight = Math.floor(image.height) 25 26 var canvas = document.getElementById('treeCanvas') 27 var scale = 1 28 if(imgWidth > img_max_width){ 29 scale = img_max_width / imgWidth 30 } 31 if(imgHeight > img_max_height){ 32 scale = scale * img_max_height / imgHeight 33 } 34 35 canvasWidth = imgWidth 36 canvasHeight = imgHeight + amplitude * 2 37 canvas.width = canvasWidth 38 canvas.height = canvasHeight 39 canvas.style.transform = 'translate3d(-50%,-50%,0) scale(' + scale + ')' 40 41 wavelength = imgWidth / period 42 cftX = 2 * Math.PI / wavelength 43 cftA = amplitude / imgWidth 44 v = wavelength * frequency 45 46 tick() 47 } 48 49 var fps = 60 // æ¯ç§å¹æ¸ 50 var interval = 1000 / fps // é£çºå¹ä¹ééé (çè«) 51 var stop = false // 忢åç« 52 var timeNow = Date.now() // ç¶åæé 53 var timeLast = timeNow // ä¸ä¸å¹æé 54 var delta = 0 // é£çºå¹ä¹éééï¼å¯¦éï¼ 55 var y = 0 56 var lastY = 0 57 var distance = 0 58 var tick = function(){ 59 if(stop) return false 60 timeNow = Date.now() 61 delta = timeNow - timeLast 62 if(delta > interval){ 63 timeLast = timeNow 64 distance += (delta / 1000 * v) 65 ctx.clearRect(0, 0, canvasWidth, canvasHeight) 66 for(var x = 0; x < imgWidth; x++){ 67 y = cftA * x * Math.sin(cftX * (x - distance)) + amplitude 68 ctx.drawImage(image, x, 0, 1, imgHeight, x, y, 1, imgHeight) 69 ctx.fillStyle = 'rgba(255,255,255,' + (x === 0 ? 0 : (y - lastY) * 0.5) + ')' 70 ctx.fillRect(x, y, 1, imgHeight) 71 lastY = y 72 } 73 } 74 requestAnimationFrame(tick) 75 } 76}
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.