Team:Shenzhen BGIC ATCG/front.html
From 2013.igem.org
(Difference between revisions)
Line 18: | Line 18: | ||
<link rel="text/javascript" class="library" href="http://code.jquery.com/jquery-2.0.3.min.js?action=raw&ctype=text/javascript"" /> | <link rel="text/javascript" class="library" href="http://code.jquery.com/jquery-2.0.3.min.js?action=raw&ctype=text/javascript"" /> | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
<body> | <body> | ||
Line 107: | Line 64: | ||
<img alt="Ball" class="eye-right" id="eye_right" src="https://static.igem.org/mediawiki/2013/4/4c/Eyewhite.png" style="top: 89px; left: 100.5px;"> | <img alt="Ball" class="eye-right" id="eye_right" src="https://static.igem.org/mediawiki/2013/4/4c/Eyewhite.png" style="top: 89px; left: 100.5px;"> | ||
</div> | </div> | ||
- | + | <script> | |
+ | var getAngle = function(Xc, Yc, Xa, Ya, Xb, Yb) { | ||
+ | var v1x = Xb - Xc; | ||
+ | var v1y = Yb - Yc; | ||
+ | var v2x = Xa - Xc; | ||
+ | var v2y = Ya - Yc; | ||
+ | return 180 * (Math.atan2(v1x, v1y) - Math.atan2(v2x, v2y)) / Math.PI | ||
+ | }; | ||
+ | var left_center_offset = { | ||
+ | left: 30, | ||
+ | top: 82 | ||
+ | }, | ||
+ | right_center_offset = { | ||
+ | left: 96, | ||
+ | top: 80 | ||
+ | }, | ||
+ | radius = 10; | ||
+ | var setEyeOffset = function(event) { | ||
+ | var offset = $(".eye_wrapper").offset(); | ||
+ | var x1 = offset.left + left_center_offset.left; | ||
+ | var y1 = offset.top + left_center_offset.top; | ||
+ | var x2 = offset.left + right_center_offset.left; | ||
+ | var y2 = offset.top + right_center_offset.top; | ||
+ | var n1 = event.clientX - x1; | ||
+ | var m1 = -(event.clientY - y1); | ||
+ | var k1 = Math.atan2(m1, n1); | ||
+ | var n2 = event.clientX - x2; | ||
+ | var m2 = -(event.clientY - y2); | ||
+ | var k2 = Math.atan2(m2, n2); | ||
+ | var x11 = (Math.cos(k1) * radius + x1).toFixed(0); | ||
+ | var y11 = (( - Math.sin(k1) * radius) + y1).toFixed(0); | ||
+ | $(".eye-left").offset({ | ||
+ | left: x11, | ||
+ | top: y11 | ||
+ | }); | ||
+ | var x22 = (Math.cos(k2) * radius + x2).toFixed(0); | ||
+ | var y22 = (( - Math.sin(k2) * radius) + y2).toFixed(0); | ||
+ | $(".eye-right").offset({ | ||
+ | left: x22, | ||
+ | top: y22 | ||
+ | }) | ||
+ | }; | ||
+ | $(window).mousemove(setEyeOffset); | ||
+ | </script> | ||
</body> | </body> | ||
</html> | </html> |
Revision as of 10:29, 13 September 2013