Changeset 13620


Ignore:
Timestamp:
05/09/12 16:16:25 (13 years ago)
Author:
tbretz
Message:
Added correct pixel mapping and a few othe rminor improvements
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/www/index.js

    r13587 r13620  
    1 var debug = true;
    2 
     1var debug = false;
     2
     3var map = [ 393, 390, 391, 394, 1098, 395, 392, 389, 387, 388, 386,
     41001, 1004, 1099, 1101, 1100, 1111, 1108, 286, 283, 377, 375, 376, 383,
     5384, 999, 1002, 1005, 1007, 1102, 1104, 1103, 1114, 1113, 1110, 1107,
     6285, 282, 280, 374, 372, 373, 380, 381, 382, 385, 1000, 1003, 1006,
     7990, 992, 1105, 1089, 1106, 1126, 1125, 1115, 1112, 1109, 287, 284,
     8281, 279, 277, 371, 369, 370, 413, 378, 379, 422, 425, 428, 431, 983,
     9986, 991, 993, 995, 1090, 1092, 1091, 1129, 1128, 1127, 1138, 1135,
     101150, 1147, 1144, 259, 256, 278, 276, 274, 368, 366, 367, 410, 411,
     11412, 419, 420, 423, 426, 429, 981, 984, 987, 989, 994, 996, 998, 1093,
     121095, 1094, 1132, 1131, 1130, 1141, 1140, 1137, 1134, 1149, 1146, 1143,
     13258, 255, 253, 275, 273, 271, 365, 363, 364, 407, 408, 409, 416, 417,
     14418, 421, 424, 427, 430, 982, 985, 988, 972, 974, 997, 1035, 1037,
     151096, 1080, 1097, 1117, 1116, 1133, 1234, 1233, 1142, 1139, 1136, 1151,
     161148, 1145, 260, 257, 254, 252, 268, 272, 270, 322, 362, 360, 361, 404,
     17405, 406, 521, 414, 415, 512, 533, 536, 539, 920, 923, 926, 911, 914,
     18973, 975, 977, 1036, 1038, 1040, 1081, 1083, 1082, 1120, 1119, 1118,
     191237, 1236, 1235, 1228, 1225, 1258, 1255, 1252, 205, 202, 199, 196,
     20193, 269, 267, 265, 323, 321, 319, 359, 357, 358, 401, 402, 403, 518,
     21519, 520, 509, 510, 531, 534, 537, 918, 921, 924, 909, 912, 915, 917,
     22976, 978, 980, 1039, 1041, 1043, 1084, 1086, 1085, 1123, 1122, 1121,
     231240, 1239, 1238, 1231, 1230, 1227, 1224, 1257, 1254, 1251, 204, 201,
     24198, 195, 192, 190, 266, 264, 262, 320, 318, 316, 356, 354, 355, 398,
     25399, 400, 515, 516, 517, 506, 507, 508, 511, 532, 535, 538, 919, 922,
     26925, 910, 913, 916, 900, 902, 979, 963, 965, 1042, 1026, 1028, 1087,
     271071, 1088, 1180, 1179, 1124, 1216, 1215, 1241, 1288, 1287, 1232, 1229,
     281226, 1259, 1256, 1253, 206, 203, 200, 197, 194, 191, 189, 187, 263,
     29261, 250, 317, 315, 313, 353, 351, 352, 467, 396, 397, 503, 513, 514,
     30575, 504, 505, 611, 524, 527, 530, 929, 932, 935, 848, 851, 854, 821,
     31824, 901, 903, 905, 964, 966, 968, 1027, 1029, 1031, 1072, 1074, 1073,
     321183, 1182, 1181, 1219, 1218, 1217, 1291, 1290, 1289, 1327, 1324, 1249,
     331246, 1243, 214, 211, 208, 142, 139, 136, 106, 103, 188, 186, 184, 251,
     34249, 247, 314, 312, 310, 350, 348, 349, 464, 465, 466, 500, 501, 502,
     35572, 573, 574, 608, 609, 522, 525, 528, 927, 930, 933, 846, 849, 852,
     36819, 822, 825, 827, 904, 906, 908, 967, 969, 971, 1030, 1032, 1034,
     371075, 1077, 1076, 1186, 1185, 1184, 1222, 1221, 1220, 1294, 1293, 1292,
     381330, 1329, 1326, 1323, 1248, 1245, 1242, 213, 210, 207, 141, 138, 135,
     39105, 102, 100, 185, 183, 181, 248, 246, 244, 311, 309, 307, 347, 345,
     40346, 461, 462, 463, 497, 498, 499, 569, 570, 571, 605, 606, 607, 610,
     41523, 526, 529, 928, 931, 934, 847, 850, 853, 820, 823, 826, 810, 812,
     42907, 891, 893, 970, 954, 956, 1033, 1017, 1019, 1078, 1062, 1079, 1171,
     431170, 1187, 1207, 1206, 1223, 1279, 1278, 1295, 1315, 1314, 1331, 1328,
     441325, 1250, 1247, 1244, 215, 212, 209, 143, 140, 137, 107, 104, 101,
     4599, 97, 182, 180, 178, 245, 243, 241, 308, 306, 304, 344, 342, 343,
     46458, 459, 460, 494, 495, 496, 566, 567, 568, 602, 603, 604, 647, 650,
     47653, 656, 659, 662, 665, 857, 860, 863, 839, 842, 845, 830, 833, 811,
     48813, 815, 892, 894, 896, 955, 957, 959, 1018, 1020, 1022, 1063, 1065,
     491064, 1174, 1173, 1172, 1210, 1209, 1208, 1282, 1281, 1280, 1318, 1317,
     501316, 1363, 1360, 1375, 1372, 1369, 1384, 1381, 1378, 133, 130, 127,
     51124, 121, 118, 115, 112, 98, 96, 94, 179, 177, 175, 242, 240, 238, 305,
     52303, 301, 332, 330, 331, 455, 456, 457, 491, 492, 493, 563, 564, 565,
     53599, 600, 601, 644, 645, 648, 651, 654, 657, 660, 663, 855, 858, 861,
     54837, 840, 843, 828, 831, 834, 836, 814, 816, 818, 895, 897, 899, 958,
     55960, 962, 1021, 1023, 1025, 1066, 1068, 1067, 1177, 1176, 1175, 1213,
     561212, 1211, 1285, 1284, 1283, 1321, 1320, 1319, 1366, 1365, 1362, 1359,
     571374, 1371, 1368, 1383, 1380, 1377, 132, 129, 126, 123, 120, 117, 114,
     58111, 109, 95, 93, 91, 176, 174, 172, 239, 237, 235, 302, 300, 298, 329,
     59327, 328, 452, 453, 454, 488, 489, 490, 560, 561, 562, 596, 597, 598,
     60641, 642, 643, 646, 649, 652, 655, 658, 661, 664, 856, 859, 862, 838,
     61841, 844, 829, 832, 835, 756, 758, 817, 792, 794, 898, 882, 884, 961,
     62945, 947, 1024, 1008, 1010, 1069, 1044, 1070, 1162, 1161, 1178, 1198,
     631197, 1214, 1270, 1269, 1286, 1306, 1305, 1322, 1342, 1341, 1367, 1364,
     641361, 1376, 1373, 1370, 1385, 1382, 1379, 134, 131, 128, 125, 122, 119,
     65116, 113, 110, 108, 43, 92, 90, 79, 173, 171, 169, 236, 234, 232, 299,
     66297, 295, 326, 324, 325, 449, 450, 451, 485, 486, 487, 557, 558, 559,
     67593, 594, 595, 629, 639, 640, 638, 695, 698, 701, 668, 671, 674, 677,
     68680, 683, 749, 752, 755, 740, 743, 746, 775, 777, 757, 759, 761, 793,
     69795, 797, 883, 885, 887, 946, 948, 950, 1009, 1011, 1013, 1045, 1047,
     701046, 1165, 1164, 1163, 1201, 1200, 1199, 1273, 1272, 1271, 1309, 1308,
     711307, 1345, 1344, 1343, 1353, 1351, 1420, 1417, 1414, 1393, 1390, 1387,
     721402, 1399, 1396, 34, 31, 28, 25, 22, 19, 62, 60, 44, 42, 40, 80, 78,
     7376, 170, 168, 166, 233, 231, 229, 296, 294, 292, 341, 339, 340, 446,
     74447, 448, 482, 483, 484, 554, 555, 556, 590, 591, 592, 626, 627, 628,
     75636, 637, 693, 696, 699, 666, 669, 672, 675, 678, 681, 747, 750, 753,
     76738, 741, 744, 774, 776, 778, 779, 760, 762, 764, 796, 798, 800, 886,
     77888, 890, 949, 951, 953, 1012, 1014, 1016, 1054, 1057, 1048, 1168,
     781167, 1166, 1204, 1203, 1202, 1276, 1275, 1274, 1312, 1311, 1310, 1348,
     791347, 1346, 1355, 1354, 1352, 1350, 1419, 1416, 1413, 1392, 1389, 1386,
     801401, 1398, 1395, 33, 30, 27, 24, 21, 18, 61, 59, 58, 41, 39, 37, 77,
     8175, 73, 167, 165, 163, 230, 228, 226, 293, 291, 289, 338, 336, 337,
     82443, 444, 445, 479, 480, 481, 551, 552, 553, 587, 588, 589, 623, 624,
     83625, 634, 635, 684, 687, 694, 697, 700, 667, 670, 673, 676, 679, 682,
     84748, 751, 754, 739, 742, 745, 787, 789, 791, 780, 765, 763, 769, 770,
     85799, 801, 803, 889, 875, 864, 952, 936, 938, 1015, 1053, 1055, 1058,
     861061, 1059, 1050, 1049, 1169, 1153, 1152, 1205, 1188, 1260, 1277, 1297,
     871296, 1313, 1337, 1336, 1349, 1332, 1356, 1412, 1410, 1408, 1421, 1418,
     881415, 1394, 1391, 1388, 1403, 1400, 1397, 35, 32, 29, 26, 23, 20, 65,
     8963, 56, 55, 53, 38, 36, 48, 74, 72, 161, 164, 162, 152, 227, 225, 224,
     90290, 288, 219, 335, 333, 334, 435, 441, 442, 440, 477, 478, 476, 549,
     91550, 548, 585, 586, 615, 621, 622, 620, 631, 632, 633, 685, 688, 691,
     92709, 706, 703, 718, 715, 712, 736, 733, 730, 727, 724, 721, 783, 785,
     93788, 790, 781, 782, 766, 767, 771, 773, 802, 804, 873, 874, 865, 866,
     94937, 939, 940, 942, 1056, 1060, 1052, 1051, 1157, 1156, 1155, 1154,
     951190, 1189, 1262, 1261, 1299, 1298, 1339, 1338, 1334, 1333, 1358, 1357,
     961411, 1409, 1406, 1404, 1424, 1427, 1430, 1433, 1436, 1439, 11, 14, 17,
     972, 5, 8, 69, 67, 64, 57, 54, 52, 51, 50, 47, 89, 88, 84, 160, 159, 151,
     98150, 148, 223, 222, 221, 218, 216, 433, 434, 437, 438, 439, 473, 474,
     99475, 546, 547, 579, 583, 584, 614, 617, 618, 619, 630, 686, 689, 692,
     100708, 705, 702, 717, 714, 711, 735, 732, 729, 726, 723, 720, 784, 786,
     101768, 772, 805, 806, 808, 880, 877, 876, 867, 869, 871, 941, 943, 944,
     1021160, 1159, 1158, 1194, 1192, 1191, 1263, 1265, 1264, 1302, 1301, 1300,
     1031340, 1335, 1407, 1405, 1422, 1425, 1428, 1431, 1434, 1437, 9, 12, 15,
     1040, 3, 6, 71, 68, 66, 49, 46, 45, 87, 83, 82, 158, 156, 149, 147, 146,
     105144, 220, 217, 432, 436, 469, 470, 471, 472, 543, 545, 577, 578, 582,
     106612, 613, 616, 710, 707, 704, 719, 716, 713, 737, 734, 731, 728, 725,
     107722, 807, 809, 878, 879, 881, 868, 870, 872, 1196, 1195, 1193, 1268,
     1081267, 1266, 1304, 1303, 1423, 1426, 1429, 1432, 1435, 1438, 10, 13, 16,
     1091, 4, 7, 86, 85, 81, 157, 155, 154, 153, 145, 468, 540, 541, 542, 544,
     110576, 580, 581, 70, 690 ];
     111
     112/*
     113
     114<a href="#" onMouseover="playsound(soundfile)">Example 1</a>
     115<a href="#" onMouseover="playsound('different.wav')">Example 2</a>
     116
     117<div id="coolmenu" onMouseover="bindsound('A', soundfile, this)">
     118
     119<script type="text/javascript">
     120
     121//
     122// JavaScript Sound effect- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
     123// Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
     124// This notice must stay intact for legal use
     125//
     126
     127var soundfile="sidebar.wav" //path to sound file, or pass in filename directly into playsound()
     128
     129function playsound(soundfile){
     130if (document.all && document.getElementById){
     131document.getElementById("soundeffect").src="" //reset first in case of problems
     132document.getElementById("soundeffect").src=soundfile
     133}
     134}
     135
     136function bindsound(tag, soundfile, masterElement){
     137if (!window.event) return
     138var source=event.srcElement
     139while (source!=masterElement && source.tagName!="HTML"){
     140if (source.tagName==tag.toUpperCase()){
     141playsound(soundfile)
     142break
     143}
     144source=source.parentElement
     145}
     146}
     147
     148</script>
     149
     150Function "bindsound()" accepts 3 parameters- 1) The tag name of the element to bind the sound to ("A" for <a>, "SPAN" for <span> etc), 2) the sound file to play, whether a variable or path to sound file, and finally, 3), the keyword "this", which should never be modified.
     151
     152// -----------------------
     153<audio controls="controls" height="50px" width="100px">
     154  <source src="song.mp3" type="audio/mpeg" />
     155  <source src="song.ogg" type="audio/ogg" />
     156<embed height="50px" width="100px" src="song.mp3" />
     157</audio>
     158// ------------------------
     159
     160*/
    3161function $(id) { return document.getElementById(id); }
    4162function trim(str) { return str.replace("/^\s\s*/", '').replace("/\s\s*$/", ''); }
     
    18176}
    19177
     178/*
     179function newWindow(newContent)
     180{
     181    if (document.referrer != "http://www.referringPageName.html")
     182        return;
     183
     184    winContent = window.open(newContent,
     185                             'nextWin',
     186                             'right=0,top=20,width=350,height=350,toolbar=no,scrollbars=no,resizable=no');
     187                             }*/
     188
    20189function onload()
    21190{
     
    26195        return;
    27196    }
     197
     198    var name = location.hash.length==0 ? "fact" : location.hash.substr(1);
    28199
    29200    /*
     
    34205          "4 -- "+navigator.userAgent);
    35206          */
    36     loadPage("fact", 0, 0);
     207    loadPage(name, 0, 0);
    37208}
    38209
     
    67238
    68239    xmlHttp.send(null);
     240
     241    location.hash = name;
    69242}
    70243
     
    8691042    switch (s)
    8701043    {
    871     case 0: this.x =  ring     - i*0.5;  this.y =       + i; break;
    872     case 1: this.x =  ring*0.5 - i;      this.y =  ring    ; break;
    873     case 2: this.x = -ring*0.5 - i*0.5;  this.y =  ring - i; break;
    874     case 3: this.x = -ring     + i*0.5;  this.y =       - i; break;
    875     case 4: this.x = -ring*0.5 + i;      this.y = -ring    ; break;
    876     case 5: this.x =  ring*0.5 + i*0.5;  this.y = -ring + i; break;
     1044    case 1: this.x =  ring     - i*0.5;  this.y =       + i; break;
     1045    case 2: this.x =  ring*0.5 - i;      this.y =  ring    ; break;
     1046    case 3: this.x = -ring*0.5 - i*0.5;  this.y =  ring - i; break;
     1047    case 4: this.x = -ring     + i*0.5;  this.y =       - i; break;
     1048    case 5: this.x = -ring*0.5 + i;      this.y = -ring    ; break;
     1049    case 0: this.x =  ring*0.5 + i*0.5;  this.y = -ring + i; break;
    8771050    }
    8781051
     
    8821055function drawFullCam(data)
    8831056{
    884     var ctx = beginDrawCam(80.5);
    885     ctx.rotate(Math.PI/2);
     1057    if (data.length!=40 && data.length!=160 && data.length!=320 && data.length!=1440)
     1058    {
     1059        alert("Data length mismatch ("+data.length+")");
     1060        return;
     1061    }
     1062
     1063    var div = map.length/data.length;
     1064    var off = data.length==320 ? 0.2 : 0;
     1065
     1066    var ctx = beginDrawCam(83);
     1067    // ctx.rotate(Math.PI/3);
    8861068
    8871069    ctx.scale(1, Math.sqrt(3)/2);
    888 
    889     drawHex(ctx, -0.5, 0, data.charCodeAt(0));
    890 
    891     var cnt  = 1;
     1070    ctx.translate(-0.5, 0);
     1071
     1072    drawHex(ctx, 0, 0, data.charCodeAt(parseInt(map[0]/div+off, 10)));
     1073
     1074    var cnt = 1;
    8921075    for (var ring=1; ring<24; ring++)
    8931076    {
     
    9001083                    continue;
    9011084
    902                 drawHex(ctx, pos.x-0.5, -pos.y, data.charCodeAt(cnt++));
     1085                var p = parseInt(map[cnt]/div+off, 10);
     1086
     1087                drawHex(ctx, pos.x, pos.y, data.charCodeAt(p));
     1088                cnt++;
    9031089            }
    9041090        }
    9051091    }
    9061092
    907     drawHex(ctx, -6.5,  22, data.charCodeAt(1438));
    908     drawHex(ctx, -6.5, -22, data.charCodeAt(1439));
     1093    drawHex(ctx, 7, -22, data.charCodeAt(parseInt(map[1438]/div+off, 10)));
     1094    drawHex(ctx, 7,  22, data.charCodeAt(parseInt(map[1439]/div+off, 10)));
    9091095
    9101096    ctx.restore();
     
    9491135{
    9501136    var vals = canv.getAttribute("data-data").split("/");
    951     var diff = vals[1]-vals[0];
     1137
     1138    var v0 = parseFloat(vals[0]);
     1139    var v1 = parseFloat(vals[1]);
     1140
     1141    var diff = v1-v0;
    9521142
    9531143    var cw = canv.width;
     
    9631153    {
    9641154        ctx.strokeStyle = "#"+color(16*i);
    965         ctx.strokeText((vals[0]-diff*(i-8)/8)+vals[2], cw-5, 135-i*15);
     1155        ctx.strokeText((v0+diff*i/8)+vals[2], cw-5, 135-i*15);
    9661156    }
    9671157}
     
    9761166    var vals = canv.getAttribute("data-data").split("/");
    9771167
    978     var dw =  3;    // tick width
     1168    var dw = 3;  // tick width
    9791169
    9801170    var fs = 8;  // font size
     
    10001190    var h = ch-mt-mb;
    10011191
    1002     ctx.strokeStyle = "#808080";
     1192    ctx.strokeStyle = "#666";
    10031193
    10041194    // --- data ---
     
    10151205    ctx.fill();
    10161206
    1017     ctx.strokeStyle = "#000000";
    1018 
    10191207    ctx.beginPath();
     1208
     1209    // --- grid ---
     1210
     1211    ctx.strokeStyle = "#eee";
     1212
     1213    for (var i=1; i<=nx; i++)
     1214    {
     1215        ctx.moveTo(ml+w/nx*i, ch-mb);
     1216        ctx.lineTo(ml+w/nx*i,    mt);
     1217    }
     1218    for (var i=0; i<ny; i++)
     1219    {
     1220        ctx.moveTo(ml,   mb+h/ny*i);
     1221        ctx.lineTo(ml+w, mb+h/ny*i);
     1222    }
     1223    ctx.stroke();
     1224    ctx.closePath();
     1225    ctx.beginPath();
     1226
     1227    ctx.strokeStyle = "#000";
    10201228
    10211229    // --- axes ---
     
    10241232    ctx.lineTo(cw-mr, ch-mb);
    10251233
    1026     for (var i=0; i<nx; i++)
     1234    for (var i=1; i<=nx; i++)
    10271235    {
    10281236        ctx.moveTo(ml+w/nx*i, ch-mb-dw);
Note: See TracChangeset for help on using the changeset viewer.