a="cEByIdcc.wc.height=500;t=cCont2dR=G=B=0;L=3;iR=iG=iB=25;iL=1;breturn </'jreturn+=i'+e+ +</-=i'+e+ -</'E'white'};P'rgb+R+','+G+','+B+')';tWt1WL;carRect;n(t1);s(t1ZputQ(i,0,0ClrcarRect;P(seTo(x+.1,y);eroke(ne.beginPath();e.To(x,ydif(e.button!=efined){s;n}else up};n;D',d,1);i=tQ};upD.reEventListenermouse',d,1K.createEcanvasK.height=K.w50;t1.body.insertBefore(K,c)Cont2dc',,0);cy.cssT=Ky.cssT='border:1px solid;backgro-color:#fff';D.body.bgColor=\"#888\";t1Cap=tCap='ro();Dup',up,0);D.write<br/>'+bPEClrZ')+'<br/>'+jRGBL'))";for(b in c="('/le/=D/und/.st/Ddocu/,24/t1./';P/)};/ext/');/down/move/.get/ment/.line/idth=/')+j('/')+b('/button>/ ()>'+e+'/strokeStyle=/t./=function(e,x,y){/<button onclick='+e+'/(0,0,c.height,c.width)/.addEventListener('mouse/,e.clientY-c.offsetTop)/(t,e.clientX-c.offsetLeft/QImageData".split("/"))a=a.replace(RegExp(c[b][0],"g"),c[b].substr(1));eval(a)
// v1.3 of js sketch app. See 471 and 355 for more notes on the original form
// plus also the my blog post on techniques (manual, then automatic with manual enhancement)
// at: http://pdaddy.wordpress.com/2010/08/31/compressing-some-js-for-the-js1k-comp/]
// and note also, I have committed the sin of modifying this code after compression and I hope they're still exactly in synch. But they mightn't
// vars
D=document;
c = D.getElementById('c');
c.width = c.height = 500;
t = c.getContext('2d');
R = G = B = 0;
L = 3;
iR = iG = iB = 25;
iL = 1;
//funx - using the same 3 params aids compression - but closure "fixes" them, so it's out
b = function (e, x, y) {
return ('<button onclick=' + e + '()>' + e + '</button>')
};
j = function (e, x, y) {
return ('<button onclick=' + e + '+=i' + e + ';P()>' + e + '+</button><button onclick=' + e + '-=i' + e + ';P()>' + e + '-</button>')
};
E = function (e, x, y) {
t.strokeStyle = t1.strokeStyle = 'white'
};
P = function (e, x, y) {
t.strokeStyle = t1.strokeStyle = 'rgb(' + R + ',' + G + ',' + B + ')';
t.lineWidth = t1.lineWidth = L;
t1.clearRect(0, 0, c.height, c.width);
n(t1, 24, 24);
s(t1, 24, 24)
};
Z = function (e, x, y) {
t.putImageData(i, 0, 0)
};
Clr = function (e, x, y) {
t.clearRect(0, 0, c.height, c.width);
P()
};
s = function (e, x, y) {
e.lineTo(x+.1, y); //the .1 is so the brush (a v.short line) appears in Opera
e.stroke()
};
n = function (e, x, y) {
e.beginPath();
e.moveTo(x, y)
};
d = function (e, x, y) {
if (e.button != undefined) {
s(t, e.clientX - c.offsetLeft, e.clientY - c.offsetTop);
n(t, e.clientX - c.offsetLeft, e.clientY - c.offsetTop)
} else up
};
down = function (e, x, y) {
n(t, e.clientX - c.offsetLeft, e.clientY - c.offsetTop);
D.addEventListener('mousemove', d, 1);
i = t.getImageData(0, 0, c.height, c.width)
};
up = function (e, x, y) {
D.removeEventListener('mousemove', d, 1)
};
//main() - which is really all init, then events drive it
K = D.createElement('canvas');
K.height = K.width = 50;
c.style.cssText=K.style.cssText='border:1px solid;background-color:#fff';
D.body.bgColor="#888";
t1.lineCap = t.lineCap = 'round';
t1 = D.body.insertBefore(K, c).getContext('2d');
P();
c.addEventListener('mousedown', down, 0);
D.addEventListener('mouseup', up, 0);
D.write('<br/>' + b('P') + b('E') + b('Clr') + b('Z') + '<br/>' + j('R') + j('G') + j('B') + j('L'))