calibration.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. var color=["#FF82AB","#CD6889","#FF1493","#CD1076","#C0FF3E"];
  2. var flag=[0,0,0,0,0,0,0,0,0];
  3. var num=0;
  4. var timestampOri = Date.now();
  5. function ShowCalibrationPoint(){
  6. document.getElementById("btn1").style.backgroundColor="#FFB6C1";
  7. document.getElementById("btn2").style.backgroundColor="#FFB6C1";
  8. document.getElementById("btn3").style.backgroundColor="#FFB6C1";
  9. document.getElementById("btn4").style.backgroundColor="#FFB6C1";
  10. document.getElementById("btn5").style.backgroundColor="#FFB6C1";
  11. document.getElementById("btn6").style.backgroundColor="#FFB6C1";
  12. document.getElementById("btn7").style.backgroundColor="#FFB6C1";
  13. document.getElementById("btn8").style.backgroundColor="#FFB6C1";
  14. document.getElementById("btn9").style.backgroundColor="#FFB6C1";
  15. document.getElementById("btn1").style.visibility='visible';
  16. document.getElementById("btn2").style.visibility='visible';
  17. document.getElementById("btn3").style.visibility='visible';
  18. document.getElementById("btn4").style.visibility='visible';
  19. document.getElementById("btn5").style.visibility='visible';
  20. document.getElementById("btn6").style.visibility='visible';
  21. document.getElementById("btn7").style.visibility='visible';
  22. document.getElementById("btn8").style.visibility='visible';
  23. document.getElementById("btn9").style.visibility='hidden';
  24. document.getElementById("btn9").disabled = false;
  25. }
  26. ShowCalibrationPoint();
  27. window.addEventListener("click", onmouseclick);
  28. function onmouseclick(event) {
  29. console.log(1111111111111)
  30. gazefilter.tracker.calibrate( //九点校正,发送当前点击位置进行校正
  31. event.timeStamp, // relative to performance.timeOrigin
  32. event.screenX, // in pixels
  33. event.screenY, // in pixels
  34. 1.0 // see note below
  35. );
  36. }
  37. function change1(){
  38. for(let i=0;i<8;i++){
  39. if(flag[i]==4)
  40. num++;
  41. }
  42. if(num==8){
  43. document.getElementById("btn9").style.visibility='visible';
  44. }else{
  45. num=0;
  46. }
  47. if(flag[0]>=4){
  48. document.getElementById("btn1").style.backgroundColor=color[flag[0]];
  49. }
  50. else{
  51. document.getElementById("btn1").style.backgroundColor=color[flag[0]];
  52. flag[0]++;
  53. }
  54. }
  55. function change2(){
  56. for(let i=0;i<8;i++){
  57. if(flag[i]==4)
  58. num++;
  59. }
  60. if(num==8){
  61. document.getElementById("btn9").style.visibility='visible';
  62. }else{
  63. num=0;
  64. }
  65. if(flag[1]>=4){
  66. document.getElementById("btn2").style.backgroundColor=color[flag[1]];
  67. }
  68. else{
  69. document.getElementById("btn2").style.backgroundColor=color[flag[1]];
  70. flag[1]++;
  71. }
  72. }
  73. function change3(){
  74. for(let i=0;i<8;i++){
  75. if(flag[i]==4)
  76. num++;
  77. }
  78. if(num==8){
  79. document.getElementById("btn9").style.visibility='visible';
  80. }else{
  81. num=0;
  82. }
  83. if(flag[2]>=4){
  84. document.getElementById("btn3").style.backgroundColor=color[flag[2]];
  85. }
  86. else{
  87. document.getElementById("btn3").style.backgroundColor=color[flag[2]];
  88. flag[2]++;
  89. }
  90. }
  91. function change4(){
  92. for(let i=0;i<8;i++){
  93. if(flag[i]==4)
  94. num++;
  95. }
  96. if(num==8){
  97. document.getElementById("btn9").style.visibility='visible';
  98. }else{
  99. num=0;
  100. }
  101. if(flag[3]>=4){
  102. document.getElementById("btn4").style.backgroundColor=color[flag[3]];
  103. }
  104. else{
  105. document.getElementById("btn4").style.backgroundColor=color[flag[3]];
  106. flag[3]++;
  107. }
  108. }
  109. function change5(){
  110. for(let i=0;i<8;i++){
  111. if(flag[i]==4)
  112. num++;
  113. }
  114. if(num==8){
  115. document.getElementById("btn9").style.visibility='visible';
  116. }else{
  117. num=0;
  118. }
  119. if(flag[4]>=4){
  120. document.getElementById("btn5").style.backgroundColor=color[flag[4]];
  121. }
  122. else{
  123. document.getElementById("btn5").style.backgroundColor=color[flag[4]];
  124. flag[4]++;
  125. }
  126. }
  127. function change6(){
  128. for(let i=0;i<8;i++){
  129. if(flag[i]==4)
  130. num++;
  131. }
  132. if(num==8){
  133. document.getElementById("btn9").style.visibility='visible';
  134. }else{
  135. num=0;
  136. }
  137. if(flag[5]>=4){
  138. document.getElementById("btn6").style.backgroundColor=color[flag[5]];
  139. }
  140. else{
  141. document.getElementById("btn6").style.backgroundColor=color[flag[5]];
  142. flag[5]++;
  143. }
  144. }
  145. function change7(){
  146. for(let i=0;i<8;i++){
  147. if(flag[i]==4)
  148. num++;
  149. }
  150. if(num==8){
  151. document.getElementById("btn9").style.visibility='visible';
  152. }else{
  153. num=0;
  154. }
  155. if(flag[6]>=4){
  156. document.getElementById("btn7").style.backgroundColor=color[flag[6]];
  157. }
  158. else{
  159. document.getElementById("btn7").style.backgroundColor=color[flag[6]];
  160. flag[6]++;
  161. }
  162. }
  163. function change8(){
  164. for(let i=0;i<8;i++){
  165. if(flag[i]==4)
  166. num++;
  167. }
  168. if(num==8){
  169. document.getElementById("btn9").style.visibility='visible';
  170. }else{
  171. num=0;
  172. }
  173. if(flag[7]>=4){
  174. document.getElementById("btn8").style.backgroundColor=color[flag[7]];
  175. }
  176. else{
  177. document.getElementById("btn8").style.backgroundColor=color[flag[7]];
  178. flag[7]++;
  179. }
  180. }
  181. function change9(){
  182. if(flag[8]>=4){
  183. document.getElementById("btn9").style.backgroundColor=color[flag[8]];
  184. document.getElementById("btn1").style.visibility='hidden';
  185. document.getElementById("btn2").style.visibility='hidden';
  186. document.getElementById("btn3").style.visibility='hidden';
  187. document.getElementById("btn4").style.visibility='hidden';
  188. document.getElementById("btn5").style.visibility='hidden';
  189. document.getElementById("btn6").style.visibility='hidden';
  190. document.getElementById("btn7").style.visibility='hidden';
  191. document.getElementById("btn8").style.visibility='hidden';
  192. document.getElementById("btn9").style.visibility='hidden';
  193. window.removeEventListener("click", onmouseclick); //九点校正完成,取消鼠标事件,并开始绘制轨迹点
  194. startTrace()
  195. }
  196. else{
  197. document.getElementById("btn9").style.backgroundColor=color[flag[8]];
  198. flag[8]++;
  199. }
  200. }