FACT++  1.0
function process_eventdata (   result)

Definition at line 392 of file index.js.

References color(), drawPix(), i, and var().

Referenced by refresh_graphics().

393 {
394  if (result.length!=160)
395  return;
396 
397  var canv = document.getElementById("canvas");
398 
399  var cw = canv.width;
400  var ch = canv.height;
401 
402  var ctx = canv.getContext("2d");
403 
404  ctx.clearRect(0, 0, cw, ch);
405 /*
406  ctx.beginPath();
407  ctx.strokeStyle = "#000000";
408  ctx.moveTo(0, 0);
409  ctx.lineTo(0, ch);
410  ctx.lineTo(cw, ch);
411  ctx.lineTo(cw, 0);
412  ctx.lineTo(0, 0);
413  ctx.stroke();
414  ctx.closePath();
415  */
416 
417  drawPix(0, 0, result.charCodeAt(0));
418 
419  var gsSin60 = Math.sqrt(3)/2;
420 
421  var cnt = 1;
422  for (var ring=1; ring<=30; ring++)
423  {
424  for (var s=0; s<6; s++)
425  {
426  for (var i=1; i<=ring; i++)
427  {
428  var x=0.;
429  var y=0.;
430 
431  switch (s)
432  {
433  case 0: x = ring-i*0.5; y = i*gsSin60; break;
434  case 1: x = ring*0.5-i; y = ring*gsSin60; break;
435  case 2: x = -(ring+i)*0.5; y = (ring-i)*gsSin60; break;
436  case 3: x = 0.5*i-ring; y = -i*gsSin60; break;
437  case 4: x = i-ring*0.5; y = -ring*gsSin60; break;
438  case 5: x = (ring+i)*0.5; y = (-ring+i)*gsSin60; break;
439  }
440 
441  if (Math.sqrt(x*x+y*y)>6.7)
442  continue;
443  if (ring==7 && i==6 && s==0)
444  continue;
445  if (ring==7 && i==1 && s==1)
446  continue;
447  if (ring==7 && i==6 && s==3)
448  continue;
449  if (ring==7 && i==1 && s==4)
450  continue;
451 
452  // Rotate by 60deg
453  var px = Math.sin(Math.PI/3)*x - Math.cos(Math.PI/3)*y;
454  var py = Math.cos(Math.PI/3)*x + Math.sin(Math.PI/3)*y;
455 
456  drawPix(px, py, result.charCodeAt(cnt));
457  cnt++;
458 
459  if (cnt==159)
460  break;
461  }
462  if (cnt==159)
463  break;
464  }
465  if (cnt==159)
466  break;
467  }
468 
469  ctx.font = "8pt Arial";
470  ctx.textAlign = "right";
471  ctx.textBaseline = "top";
472 
473  ctx.strokeStyle = "#"+color(0);
474  ctx.strokeText("-2.0V", cw-5, 135);
475 
476  ctx.strokeStyle = "#"+color(16);
477  ctx.strokeText("-1.5V", cw-5, 120);
478 
479  ctx.strokeStyle = "#"+color(32);
480  ctx.strokeText("-1.0V", cw-5, 105);
481 
482  ctx.strokeStyle = "#"+color(48);
483  ctx.strokeText("-0.5V", cw-5, 90);
484 
485  ctx.strokeStyle = "#"+color(64);
486  ctx.strokeText("0V", cw-5, 70);
487 
488  ctx.strokeStyle = "#"+color(80);
489  ctx.strokeText("0.5V", cw-5, 50);
490 
491  ctx.strokeStyle = "#"+color(86);
492  ctx.strokeText("1.0V", cw-5, 35);
493 
494  ctx.strokeStyle = "#"+color(102);
495  ctx.strokeText("1.5V", cw-5, 20);
496 
497  ctx.strokeStyle = "#"+color(127);
498  ctx.strokeText("2.0V", cw-5, 5);
499 
500 }
int i
Definition: db_dim_client.c:21
po::typed_value< T > * var(T *ptr=0)
function drawPix(x, y, col)
Definition: index.js:373
function color(col)
Definition: index.js:358

+ Here is the call graph for this function:

+ Here is the caller graph for this function: