<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>音量旋钮调整原理</title> </head> <body onselectstart="return false"> <span id=box></span> <br> <span id="round" style="CURSOR: hand; background-image: url('http://netroom.hbu.edu.cn/personal/stroll/round.gif'); width: 150px; background-repeat: no-repeat; height: 150px" onmousedown="CMP=true" onmouseup="CMP=false" onmouseout="CMP=false"> <img id="point" style="LEFT: 0px; CURSOR: hand; POSITION: relative; TOP: 0px; z-index: -1" src="http://netroom.hbu.edu.cn/personal/stroll/point.gif" border="0" width="10" height="10"> </span> <script> with(point.style) { pixelLeft = Math.round((round.offsetWidth/2)) pixelTop = Math.round((round.offsetHeight/2)-50) } var CMP = false var Angle1 = Math.PI/180 //一度的弧度 var AngleList = "" for(i=1;i<300;i++) { AngleList += i+","+Math.round(100*Math.sin(Angle1*i))+","+Math.round(100*Math.cos(Angle1*i)) if(i<299) AngleList += ";" } function round.onmousemove() { var X = Math.round(event.clientX - round.offsetLeft - (round.offsetWidth/2)) var Y = Math.round((round.offsetHeight/2) + round.offsetTop - event.clientY ) var R = Math.round(Math.sqrt(Math.pow(X,2)+Math.pow(Y,2))) var Sin = Math.round(100*X/R) var Cos = Math.round(100*Y/R) var re = eval("/\\d+,"+Sin+","+Cos+"/") if(re.test(AngleList)&&CMP) { box.innerText="音量:"+Math.round(100*((parseInt(AngleList.match(re)[0].split(",")[0])-1)/298))+" 角度:"+AngleList.match(re)[0].split(",")[0]+" R: "+R+" X: "+X+" Y: "+Y+" Sin: "+Sin+" Cos: "+Cos with(point.style) { pixelLeft = Math.round((round.offsetWidth/2)+50*(X/R)) pixelTop = Math.round((round.offsetHeight/2)-50*(Y/R)) } } } </script> </body> </html> 载入中... 载入中...
Copyright © 2000-2006 Nkcn.Net 天津网站优化 All Rights Reserve.