-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.min.html
1 lines (1 loc) · 1.95 KB
/
index.min.html
1
<!DOCTYPE html><html manifest="/colorGrid/c"><head><title>Experiment with Color</title><meta name="mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-capable" content="yes"/><style>body{margin:0}table{height:100%;position:fixed;width:100%}td{background:#7F7F7F;height:4%;padding:0;-moz-transition:all .15s;-webkit-transition:all .15s;transition:all .15s;width:4%}</style></head><body><script>!function(){"use strict";var t=[],a=5,n={x:20,y:20},r=200,o=2*a+1,e=2*r+1,d=function(t,a,n,r){r=r||!1,t.addEventListener?t.addEventListener(a,n,r):t.attachEvent?t.attachEvent("on"+a,n):t["on"+a]=n},l=function(a){var n,o,d;a=a||window.event,n=a.target?a.target:a.srcElement,o=n.dataset.x,d=n.dataset.y,t[d][o].r=t[d][o].r+Math.floor(Math.random()*e)-r,t[d][o].g=t[d][o].g+Math.floor(Math.random()*e)-r,t[d][o].b=t[d][o].b+Math.floor(Math.random()*e)-r,n.style.backgroundColor="rgb("+t[d][o].r+","+t[d][o].g+","+t[d][o].b+")"},h=function(){var a,r=document.createElement("table"),o=0,e=0,h=function(a,r){var e;for(a;a<n.x;a+=1)e=document.createElement("td"),e.dataset.x=a,e.dataset.y=o,r.appendChild(e),t[o][a]={node:e,r:127,g:127,b:127}};for(r.cellSpacing="0",o;o<n.y;o+=1)a=document.createElement("tr"),t[o]=[],h(e,a),r.appendChild(a);document.body.appendChild(r),d(r,"click",l)},c=function(){var n=0,r=0,e=function(t,n){var r,e={r:t.r,g:t.g,b:t.b},d=1;for(r in n)n[r]&&(d+=1,e.r+=n[r].r,e.g+=n[r].g,e.b+=n[r].b);e.r=e.r/d,e.g=e.g/d,e.b=e.b/d,e.r+=Math.floor(Math.random()*o)-a,e.g+=Math.floor(Math.random()*o)-a,e.b+=Math.floor(Math.random()*o)-a,t.r=Math.max(Math.min(Math.round(e.r),255),0),t.g=Math.max(Math.min(Math.round(e.g),255),0),t.b=Math.max(Math.min(Math.round(e.b),255),0),t.node.style.backgroundColor="rgb("+t.r+","+t.g+","+t.b+")"},d=function(a,n){var r={};for(n;n<t[a].length;n+=1)r.u=a?t[a-1][n]:null,r.l=n?t[a][n-1]:null,r.r=n<t[a].length-1?t[a][n+1]:null,e(t[a][n],r)};for(n;n<t.length;n+=1)d(n,r)};h(),setInterval(function(){c()},150)}();</script></body></html>