tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

bug1897792.js (2644B)


      1 function drawGrid() {
      2  var n = 32;
      3  var gridVertices = [];
      4  var gridColors = [];
      5  var gridSecColors = [];
      6  var currentVertex = 0;
      7  var currentColor = 0;
      8  var currentSecColor = 0;
      9  var z = -2.0;
     10  for (var i = -n; i < n; ++i) {
     11    var x1 = i / n;
     12    var x2 = (i + 1) / n;
     13    for (var j = -n; j < n; ++j) {
     14      var y1 = j / n;
     15      var y2 = (j + 1) / n;
     16      gridVertices[currentVertex++] = x1;
     17      gridVertices[currentVertex++] = y1;
     18      gridVertices[currentVertex++] = z;
     19      gridColors[currentColor++] = 1.0 - (x1 + y1 + 2.0) / 4.0;
     20      gridColors[currentColor++] = (x1 + 1.0) / 2.0;
     21      gridColors[currentColor++] = (y1 + 1.0) / 2.0;
     22      gridSecColors[currentSecColor++] = 1.0 - (x2 + y2 + 2.0) / 4.0;
     23      gridSecColors[currentSecColor++] = (x2 + 1.0) / 2.0;
     24      gridSecColors[currentSecColor++] = (y2 + 1.0) / 2.0;
     25 
     26      gridVertices[currentVertex++] = x2;
     27      gridVertices[currentVertex++] = y1;
     28      gridVertices[currentVertex++] = z;
     29      gridColors[currentColor++] = 1.0 - (x2 + y1 + 2.0) / 4.0;
     30      gridColors[currentColor++] = (x2 + 1.0) / 2.0;
     31      gridColors[currentColor++] = (y1 + 1.0) / 2.0;
     32      gridSecColors[currentSecColor++] = 1.0 - (x1 + y2 + 2.0) / 4.0;
     33      gridSecColors[currentSecColor++] = (x1 + 1.0) / 2.0;
     34      gridSecColors[currentSecColor++] = (y2 + 1.0) / 2.0;
     35 
     36      gridVertices[currentVertex++] = z;
     37      gridColors[currentColor++] = 1.0 - (x2 + y2 + 2.0) / 4.0;
     38      gridColors[currentColor++] = (x2 + 1.0) / 2.0;
     39      gridColors[currentColor++] = (y2 + 1.0) / 2.0;
     40      gridSecColors[currentSecColor++] = 1.0 - (x1 + y1 + 2.0) / 4.0;
     41      gridSecColors[currentSecColor++] = (x1 + 1.0) / 2.0;
     42 
     43      gridVertices[currentVertex++] = x2;
     44      gridVertices[currentVertex++] = y2;
     45      gridVertices[currentVertex++] = z;
     46      gridColors[currentColor++] = 1.0 - (x2 + y2 + 2.0) / 4.0;
     47      gridColors[currentColor++] = (x2 + 1.0) / 2.0;
     48      gridColors[currentColor++] = (y2 + 1.0) / 2.0;
     49 
     50      gridVertices[currentVertex++] = x1;
     51      gridVertices[currentVertex++] = y2;
     52      gridVertices[currentVertex++] = z;
     53      gridColors[currentColor++] = 1.0 - (x1 + y2 + 2.0) / 4.0;
     54      gridColors[currentColor++] = (x1 + 1.0) / 2.0;
     55      gridColors[currentColor++] = (y2 + 1.0) / 2.0;
     56 
     57      gridVertices[currentVertex++] = x1;
     58      gridVertices[currentVertex++] = y1;
     59      gridVertices[currentVertex++] = z;
     60      gridColors[currentColor++] = 1.0 - (x1 + y1 + 2.0) / 4.0;
     61    }
     62  }
     63  return gridColors;
     64 }
     65 function test() {
     66  var arr = drawGrid();
     67  var res = 0;
     68  for (var i = 0; i < arr.length; i++) {
     69    res += arr[i];
     70  }
     71  assertEq(res, 32832);
     72 }
     73 test();