- Author:
- Howard Yeend
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- puremango.co.uk
- Compo:
- classic
- Demo link:
- https://js1k.com/2010-first/demo/574
- Shortlink:
- https://js1k.com/574
- Blog post:
- please update here!
- Bytes:
- 713
- Chars:
- 713
- Submission
var o=document.body,c=o.children[0],w=4096,n=256,t=c.getContext("2d"),s=x=y=0;c.width=c.height=w;c.style.background='#DDD';h=document.createElement('p');h.innerHTML='<p style="font-family:verdana;font-size:10pt;">All<b style="color:red;">R</b><b style="color:#0F0;">G</b><b style="color:blue;">B</b> entry in JS, in 719b. Rendering every RGB colour exactly once '+w+'x'+w+'px - '+(w*w)+' cols.</p>';o.insertBefore(h,o.firstChild);function d(){e=s+1;for(r=s;r++<e;)for(g=0;g++<n;)for(b=0;b++<n;){t.fillStyle="rgb("+r+","+g+","+b+")";t.fillRect(x,y,1,1);if(++x>=w){x=0;y++;if(y>300&&y%5==0){scroll(0,y-300);}}}if(e<=n){s=e;setTimeout(d,1);}else alert('done');}if(confirm('This will hang Safari til done. Run?'))d();
- Description
- A simple AllRGB entry in 1k. Generates an image containing every possible RGB colour.
Draws onto the canvas using every single RGB colour, 4096x4096px, 16777216 colours; see allrgb.com for the general idea. This is a port of my PHP entry to allrgb - http://allrgb.com/grid-one
It's very basic, but fun. Slow in safari, but it works. Fastest in Opera then Chrome. Best in firefox as you can save the canvas as an image and check it's got all the colours in gimp (Colors->Info->Colorcube analysis).
- Base64 encoded
dmFyIG89ZG9jdW1lbnQuYm9keSxjPW8uY2hpbGRyZW5bMF0sdz00MDk2LG49MjU2LHQ9Yy5nZXRDb250ZXh0KCIyZCIpLHM9eD15PTA7Yy53aWR0aD1jLmhlaWdodD13O2Muc3R5bGUuYmFja2dyb3VuZD0nI0RERCc7aD1kb2N1bWVudC5jcmVhdGVFbGVtZW50KCdwJyk7aC5pbm5lckhUTUw9JzxwIHN0eWxlPSJmb250LWZhbWlseTp2ZXJkYW5hO2ZvbnQtc2l6ZToxMHB0OyI+QWxsPGIgc3R5bGU9ImNvbG9yOnJlZDsiPlI8L2I+PGIgc3R5bGU9ImNvbG9yOiMwRjA7Ij5HPC9iPjxiIHN0eWxlPSJjb2xvcjpibHVlOyI+QjwvYj4gZW50cnkgaW4gSlMsIGluIDcxOWIuIFJlbmRlcmluZyBldmVyeSBSR0IgY29sb3VyIGV4YWN0bHkgb25jZSAnK3crJ3gnK3crJ3B4IC0gJysodyp3KSsnIGNvbHMuPC9wPic7by5pbnNlcnRCZWZvcmUoaCxvLmZpcnN0Q2hpbGQpO2Z1bmN0aW9uIGQoKXtlPXMrMTtmb3Iocj1zO3IrKzxlOylmb3IoZz0wO2crKzxuOylmb3IoYj0wO2IrKzxuOyl7dC5maWxsU3R5bGU9InJnYigiK3IrIiwiK2crIiwiK2IrIikiO3QuZmlsbFJlY3QoeCx5LDEsMSk7aWYoKyt4Pj13KXt4PTA7eSsrO2lmKHk+MzAwJiZ5JTU9PTApe3Njcm9sbCgwLHktMzAwKTt9fX1pZihlPD1uKXtzPWU7c2V0VGltZW91dChkLDEpO31lbHNlIGFsZXJ0KCdkb25lJyk7fWlmKGNvbmZpcm0oJ1RoaXMgd2lsbCBoYW5nIFNhZmFyaSB0aWwgZG9uZS4gUnVuPycpKWQoKTs=
- Original source
// declare shorthand vars
var o=document.body,c=o.children[0],w=4096,n=256,t=c.getContext("2d"),s=x=y=0;
// set canvas dimensions and background
c.width=c.height=w;c.style.background='#DDD';
// add a pretty description
h=document.createElement('p');
h.innerHTML='<p style="font-family:verdana;font-size:10pt;">All<b style="color:red;">R</b><b style="color:#0F0;">G</b><b style="color:blue;">B</b> entry in JS, in 719b. Rendering every RGB colour exactly once '+w+'x'+w+'px - '+(w*w)+' cols.</p>';
o.insertBefore(h,o.firstChild);
// draw function:
function d(){
// draw the next few reds
e=s+1;
// draw full blue and green for each red
for(r=s;r++<e;)for(g=0;g++<n;)for(b=0;b++<n;){
// set the colour
t.fillStyle="rgb("+r+","+g+","+b+")";
// draw a pixel
t.fillRect(x,y,1,1);
// increment x and y if needed, and scroll the page so the user can see what's going on.
if(++x>=w){x=0;y++;if(y>300 && y%5==0) {scroll(0,y-300);}}
}
// chunk the drawing so it doesn't cause a "this script is running slowly" message
// this also prevents the browser from becoming completely non-responsive. You can still close the tab while it's running
if(e<=n){s=e;setTimeout(d,1);} else alert('done');
}
// warn user
if(confirm('This will hang Safari til done. Run?')) d();