Commits

Eric Fredricksen committed 8f34a3b

Mini-jquery-ize

Comments (0)

Files changed (1)

   window.oRequestAnimationFrame ||
   window.msRequestAnimationFrame;
 
-var pre = document.querySelector('#ascii');
-var video = document.querySelector('video');
-var canvas = document.querySelector('canvas');
-var fps = document.querySelector('#fps');
+function $(s) { return document.querySelector(s) }
 
-var pow = Math.pow;  // legend says this speeds things up
+var pre = $('#ascii');
+var video = $('video');
+var canvas = $('canvas');
+var fps = $('#fps');
 
 var GAMMA = 0.45;
 var HREVERSE = true;
 var MESSAGE;
 
-function msg(id) {
-  MESSAGE = 
-    document.querySelector('#title').innerText +
-    document.querySelector('#' + id).innerText;
-}
+function msg(id) { MESSAGE = $('#title').innerText + $('#' + id).innerText }
 
 function go() {
   msg('skzzt');
     if (lineno < H) {
       for (var x = 0; x < W; ++x) {
         var v = wave(Math.random(), x, y);
-        v = 1 - pow(v, GAMMA);
+        v = 1 - Math.pow(v, GAMMA);
         line += palette[(v * palette.length) >> 0];  
       }
       line = embedstr(line, msg[lineno - msgline], ' ', skzzt);
       var g = pixels.data[p++];
       var b = pixels.data[p++];
       var v = Math.max(r, g, b) / 255;
-      v = 1 - pow(v, GAMMA);
+      v = 1 - Math.pow(v, GAMMA);
       v = (v * palette.length) >> 0;
       v = Math.max(0, Math.min(palette.length - 1, v));
       ascii += palette[v];