Permalink
Browse files

Create asciiMorph.min.js

  • Loading branch information...
1 parent 67fed5a commit e393389074cf4dcab4d8623c09a853656ae68b61 @tholman committed on GitHub Nov 16, 2016
Showing with 1 addition and 0 deletions.
  1. +1 −0 asciiMorph.min.js
View
@@ -0,0 +1 @@
+var AsciiMorph=function(){"use strict";function f(a,b){for(var c in b)c in a||(a[c]=b[c]);return a}function g(a,b){if(b<1)return"";for(var c="";b>1;)1&b&&(c+=a),b>>=1,a+=a;return c+a}function h(a,b,c){return a.substr(0,b)+c+a.substr(b+c.length)}function i(c,d){a=c,b=d}function j(a){var c,d={x:0,y:a.length};for(c=0;c<a.length;c++)a[c].length>d.x&&(d.x=a[c].length);for(c=0;c<a.length;c++)a[c].length<d.x&&(a[c]=a[c]+g(" ",d.x-a[c].length));for(var e={x:Math.floor((b.x-d.x)/2),y:Math.floor((b.y-d.y)/2)},c=0;c<a.length;c++)a[c]=g(" ",e.x)+a[c]+g(" ",e.x);for(var c=0;c<b.y;c++)c<e.y?a.unshift(g(" ",b.x)):c>e.y+d.y&&a.push(g(" ",b.x));return a}function k(a){for(var b,c=null,d=!1,e=0;e<a.length;e++){var f=a[e];b=f.search(/\S/),b===-1&&(b=null);for(var g=0;g<f.length;g++)" "!=f[g]&&(c=g);null!==b&&null!==c&&(a=l(a,e,b,c),d=!0),b=null,c=null}return!!d&&a}function l(a,c,d,e){var f={x:Math.floor(b.x/2),y:Math.floor(b.y/2)},g=1;c>f.y&&(g=-1);a[c][d],a[c][e];return a[c]=h(a[c],d," "),a[c]=h(a[c],e," "),e-1!=d+1&&d!==e&&d+1!==e?(a[c+g]=h(a[c+g],d+1,"+*/\\".substr(Math.floor(Math.random()*"+*/\\".length),1)),a[c+g]=h(a[c+g],e-1,"+*/\\".substr(Math.floor(Math.random()*"+*/\\".length),1))):d!==e&&d+1!==e||c+1===f.y||c-1===f.y||c===f.y||(a[c+g]=h(a[c+g],d,"+*/\\".substr(Math.floor(Math.random()*"+*/\\".length),1)),a[c+g]=h(a[c+g],e,"+*/\\".substr(Math.floor(Math.random()*"+*/\\".length),1))),a}function m(a){var b=j(a.slice());n(b)}function n(b){a.innerHTML="";for(var d=0;d<b.length;d++)a.innerHTML=a.innerHTML+b[d]+"\n";c=b}function o(a){clearTimeout(e);var b=p(a.slice());q(b)}function p(a){for(var b=[],d=[],e=c,f=0;f<100;f++){var g=k(e);if(g===!1)break;b.push(g.slice(0)),e=g}var h=j(a);d.unshift(h.slice(0));for(var f=0;f<100;f++){var g=k(h);if(g===!1)break;d.unshift(g.slice(0)),h=g}return b.concat(d)}function q(a){d=a,r()}function r(){e=setTimeout(function(){n(d[0]),d.shift(),d.length>0&&r()},20)}function s(a,b){return a&&b?void i(a,b):void console.log("sorry, I need an element and a canvas size")}var a=null,b={},c=[],d=[],e=null;return f(s,{render:m,morph:o})}();

0 comments on commit e393389

Please sign in to comment.