Changeset 17788 for trunk/FACT++
- Timestamp:
- 05/07/14 13:43:37 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/www/viewer/index.js
r17775 r17788 884 884 } 885 885 886 function getIndex(id, mouse)887 {888 var canv = document.getElementById(id);889 890 var scale = 83;891 892 var w = Math.min(canv.width/scale, canv.height/scale);893 894 //ctx.translate(canv.width/2, canv.height/2);895 //ctx.scale(w*2, w*2);896 //ctx.scale(1, Math.sqrt(3)/2);897 //ctx.translate(-0.5, 0);898 899 mouse.x -= canv.width/2;900 mouse.y -= canv.height/2;901 mouse.x /= w*2;902 mouse.y /= w*2;903 mouse.y /= Math.sqrt(3)/2;904 mouse.x -= -0.5;905 906 if (isInside(0, 0, mouse))907 return 0;908 909 var cnt = 1;910 for (var ring=1; ring<24; ring++)911 {912 for (var s=0; s<6; s++)913 {914 for (var i=1; i<=ring; i++)915 {916 var pos = new Position(s, ring, i);917 if (pos.d() - pos.x > 395.75)918 continue;919 920 if (isInside(pos.x, pos.y, mouse))921 return cnt;922 cnt++;923 }924 }925 }926 927 if (isInside(7, -22, mouse))928 return 1438;929 if (isInside(7, 22, mouse))930 return 1439;931 932 return -1;933 }934 935 886 var inprogress = { }; 936 887 function moveElement(id, n, target, callback) … … 1232 1183 initCameraCoordinates(); 1233 1184 1185 function getIndex(id, mouse) 1186 { 1187 var canv = document.getElementById(id); 1188 1189 var scale = 83; 1190 1191 var w = Math.min(canv.width/scale, canv.height/scale); 1192 1193 //ctx.translate(canv.width/2, canv.height/2); 1194 //ctx.scale(w*2, w*2); 1195 //ctx.scale(1, Math.sqrt(3)/2); 1196 //ctx.translate(-0.5, 0); 1197 1198 mouse.x -= canv.width/2; 1199 mouse.y -= canv.height/2; 1200 mouse.x /= w*2; 1201 mouse.y /= w*2; 1202 mouse.y /= Math.sqrt(3)/2; 1203 mouse.x -= -0.5; 1204 1205 for (var i=0; i<1440; i++) 1206 if (isInside(coord[i][0], coord[i][1], mouse)) 1207 return i; 1208 1209 return -1; 1210 } 1211 1212 1234 1213 function hueToRGB(hue) 1235 1214 { … … 1314 1293 } 1315 1294 1316 var positions = new Array(1440);1317 1318 1319 1295 function drawFullCam(id) 1320 1296 {
Note:
See TracChangeset
for help on using the changeset viewer.